共用方式為


MobileListItem.Implicit(String to MobileListItem) 運算子

定義

提供由 StringMobileListItem 的隱含轉換。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 mobile Apps & Sites with ASP.NET

public:
 static operator System::Web::UI::MobileControls::MobileListItem ^(System::String ^ s);
public static implicit operator System.Web.UI.MobileControls.MobileListItem (string s);
static member op_Implicit : string -> System.Web.UI.MobileControls.MobileListItem
Public Shared Widening Operator CType (s As String) As MobileListItem

參數

s
String

要轉換的字串。

傳回

MobileListItem,其中 Text 設定為指定的 String

範例

下列程式代碼範例會使用字串中的隱含轉換來建立多個 MobileListItem 物件,並將其新增至 List 控件。

<%@ Page Language="C#" 
    Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls" 
    Assembly="System.Web.Mobile" %>

<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        MobileListItem mi;
        
        // Use implicit conversion to create 
        // new MobileListItem objects from strings
        mi = "One";
        List1.Items.Add(mi);
        mi = "Two";
        List1.Items.Add(mi);
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
    <mobile:form id="form1" runat="server">
        <mobile:List ID="List1" Runat="server">
        </mobile:List>
    </mobile:form>
</body>
</html>
<%@ Page Language="VB" 
    Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls" 
    Assembly="System.Web.Mobile" %>

<script runat="server">
    Protected Sub Page_Load(ByVal sender As Object, _
        ByVal e As System.EventArgs)
        Dim mi As MobileListItem
        
        ' Use implicit conversion to create 
        ' new MobileListItem objects from strings
        mi = "One"
        List1.Items.Add(mi)
        mi = "Two"
        List1.Items.Add(mi)
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
    <mobile:form id="form1" runat="server">
        <mobile:List ID="List1" Runat="server" />
    </mobile:form>
</body>
</html>

備註

MobileListItem隱含轉換所建立的物件會使用字串輸入作為其 Text 屬性的值。

適用於

另請參閱