String.Substring 메서드 (Int32)
.NET Framework 2.0
이 인스턴스에서 부분 문자열을 검색합니다. 부분 문자열은 지정된 문자 위치에서 시작됩니다.
네임스페이스: System
어셈블리: mscorlib(mscorlib.dll)
어셈블리: mscorlib(mscorlib.dll)
다음 코드 예제에서는 문자열에서 부분 문자열을 얻는 방법을 보여 줍니다.
using System; public class SubStringTest { public static void Main() { string [] info = {"Name: Felica Walker", "Title: Mz.", "Age: 47", "Location: Paris", "Gender: F"}; int found = 0; Console.WriteLine("The initial values in the array are:"); foreach (string s in info) Console.WriteLine(s); Console.WriteLine("{0}We want to retrieve only the key information. That is:", Environment.NewLine); foreach (string s in info) { found = s.IndexOf(":"); Console.WriteLine(s.Substring(found + 1).Trim()); } } }
import System.*;
public class SubStringTest
{
public static void main(String[] args)
{
String info[] = { "Name: Felica Walker", "Title: Mz.",
"Age: 47", "Location: Paris", "Gender: F" };
int found = 0;
Console.WriteLine("The initial values in the array are:");
for (int iCtr = 0; iCtr < info.get_Length(); iCtr++) {
String s = info[iCtr];
Console.WriteLine(s);
}
Console.WriteLine("{0}We want to retrieve only the key information."
+ " That is:", Environment.get_NewLine());
for (int iCtr = 0; iCtr < info.get_Length(); iCtr++) {
String s = info[iCtr];
found = s.IndexOf(":");
Console.WriteLine(s.Substring(found + 1).Trim());
}
} //main
} //SubStringTest
import System; public class SubStringTest { public static function Main() : void { var info : String [] = ["Name: Felica Walker", "Title: Mz.", "Age: 47", "Location: Paris", "Gender: F"]; var found : int = 0; Console.WriteLine("The initial values in the array are:"); for (var i : int in info) Console.WriteLine(info[i]); Console.WriteLine("{0}We want to retrieve only the key information. That is:", Environment.NewLine); for (i in info) { found = info[i].IndexOf(":"); Console.WriteLine(info[i].Substring(found + 1).Trim()); } } } SubStringTest.Main();
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.