C# 클래스 Exceptions.ReturnCodeImplementation

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

공개 메소드들

메소드 설명
CharToInt ( char c ) : int

文字→整数

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

文字列→整数

메소드 상세

CharToInt() 공개 정적인 메소드

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

Main() 공개 정적인 메소드

public static Main ( ) : void
리턴 void

StringToInt() 공개 정적인 메소드

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