C# Class Exceptions.ReturnCodeImplementation

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

Public Methods

Method Description
CharToInt ( char c ) : int

文字→整数

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

文字列→整数

Method Details

CharToInt() public static method

文字→整数
public static CharToInt ( char c ) : int
c char
return int

Main() public static method

public static Main ( ) : void
return void

StringToInt() public static method

文字列→整数
public static StringToInt ( string str ) : int
str string
return int