次の方法で共有


MobileListItem.Implicit(String to MobileListItem) 演算子

定義

String から MobileListItem への暗黙の型変換を提供します。 この 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 として文字列入力を使用します。

適用対象

こちらもご覧ください