.


:




:

































 

 

 

 


,




string[] parts = str.Split (seps);

.

string[] parts = str.Split(seps, StringSplitOptions.RemoveEmptyEntries);

.

:

:

| | | | |

, , - , "" , .

, , . , Split () " 100" , "" "100". , "" ( ), " ".

, , , 10 + 5, , .

// .

Using System;

class TokenizeDemo { static void Main() { string[] input = {

"100 + 19",

"100 / 3,3",

_3 * 9..r

"100 - 87"

};

char[] seps = {' '};

for (int i=0; i < input.Length; i++) {

//

string[] parts = input[i].Split(seps);

Console.Write(": ");

for (int j=0; j < parts.Length; j++)

Console.Write(parts[j] + " ");

Console.Write(", : "); double n = Double.Parse(parts[0]); double n2 = Double.Parse(parts[2]);

switch(parts[1]) { case

Console.WriteLine(n + n2); break; case

Console.WriteLine (n - n2); break; case

Console.WriteLine(n * n2); break; case "/":

Console.WriteLine(n / n2); break;

}

}

}

}

.

: 100 + 19, : 119

: 100 / 3,3, : 30,3030303030303

: -3*9, : -27

: 100 - 87, : 13

4.0, .NET Framework Join ().

public static string Join(string separator, params object[] values) public static string Join(string separator, IEnumerable<string>[] values) public static string Join<T>(string separator, IEnumerable<T>[] values)

, values. , , values. , , values. , separator.

 

. . , "print'7, . . , , . , , , . C# .

Trim ().

Public string Trim()

public string Trim(params char[] trimChars)

Trim () . trimChars. .

. PadLef t ().

public string PadLeft(int totalWidth)

public string PadLeft(int totalWidth, char paddingChar)

PadLef t () , totalWidth. , paddingChar, , totalWidth. . totalWidth , .

PadRight ().

public string PadRight(int totalWidth)

public string PadRight(int totalWidth, char paddingChar)

PadLef t () , totalWidth.

, paddingChar, , totalWidth.B . totalWidth , .





:


: 2016-12-03; !; : 331 |


:

:

, , .
==> ...

1935 - | 1591 -


© 2015-2024 lektsii.org - -

: 0.016 .