c# throw exception example



class ProgramLog
{
    System.IO.FileStream logFile = null;
    void OpenLog(System.IO.FileInfo fileName, System.IO.FileMode mode) {}

    void WriteLog()
    {
        if (!this.logFile.CanWrite)
        {
            throw new System.InvalidOperationException("Logfile cannot be read-only");
        }
        // Else write data to the log and return.
    }
}

https://msdn.microsoft.com/ko-kr/library/ms173163.aspx

내 코드

throw new System.InvalidOperationException("필드의 갯수가 맞지 않아 파일을 무시 합니다.");



댓글