C# Class Exceptions.ReturnCodeImplementation

エラーがあるときには特定の値を返すような実装。 この場合、「戻り値は必ず正」という縛りの中だから、-1 とかを使える。 この他、「int? 型にしておいて、不正な入力の場合には null を返す」とかもよくやる。
この手の、文字列を整数化するような場合、int.TryParse(string, out int) みたいな、bool戻り値を使う場合もよくある。
Afficher le fichier Open project: ufcpp/UfcppSample

Méthodes publiques

Méthode Description
CharToInt ( char c ) : int

文字→整数

Main ( ) : void
StringToInt ( string str ) : int

文字列→整数

Method Details

CharToInt() public static méthode

文字→整数
public static CharToInt ( char c ) : int
c char
Résultat int

Main() public static méthode

public static Main ( ) : void
Résultat void

StringToInt() public static méthode

文字列→整数
public static StringToInt ( string str ) : int
str string
Résultat int