C#のUri.ToString()メソッド
C#のUri.ToString()メソッドは、指定されたUriインスタンスの正規の文字列表現を取得するために使用されます。
構文
以下は構文です-
public override string ToString ();
例
Uri.ToString()メソッドを実装する例を見てみましょう-
using System;
public class Demo {
public static void Main(){
Uri newURI1 = new Uri("https://www.tutorialspoint.com/");
Console.WriteLine("URI = "+newURI1);
Console.WriteLine("String representation = "+newURI1.ToString());
Uri newURI2 = new Uri("https://www.tutorialspoint.com/jquery.htm#abcd");
Console.WriteLine("\nURI = "+newURI2);
Console.WriteLine("String representation = "+newURI2.ToString());
if(newURI1.Equals(newURI2))
Console.WriteLine("\nBoth the URIs are equal!");
else
Console.WriteLine("\nBoth the URIs aren't equal!");
Uri res = newURI1.MakeRelativeUri(newURI2);
Console.WriteLine("Relative uri = "+res);
}
} 出力
これにより、次の出力が生成されます-
URI = https://www.tutorialspoint.com/ String representation = https://www.tutorialspoint.com/ URI = https://www.tutorialspoint.com/jquery.htm#abcd String representation = https://www.tutorialspoint.com/jquery.htm#abcd Both the URIs aren't equal! Relative uri = jquery.htm#abcd
-
C#のCharEnumerator.ToString()メソッド
C#のCharEnumerator.ToString()メソッドは、現在のオブジェクトを表す文字列を取得します。 構文 構文は次のとおりです- public virtual string ToString(); 例 CharEnumerator.ToString()メソッドを実装する例を見てみましょう- using System; public class Demo { public static void Main(){ string strNum = "This is it!"; &n
-
C#のConvert.ToStringメソッド
ToString()メソッドを使用して、指定された値を同等の文字列に変換します。 ブール値を初期化します。 bool boolVal = false; ここで、文字列に変換するには、ToString()メソッドを使用します。 Convert.ToString(boolVal) 以下は完全な例です。 例 using System; public class Demo { public static void Main() { bool boolVal = false; Consol