exなんとか…
中間おすすめ記事: 思考ちゃんねる
.mm-ttl{ font-size:14px; margin-bottom: 15px;}
.mm-ttl .Ttl-mil{ font-size:14px !important; color: gray;}
.mm-ttl .Ttl-mil span{ color: rgb(0, 128, 0); font-size: 15px !important; font-weight: bold;}
.at_out ul{-webkit-padding-start: 0; margin: 0 !important; padding: 0;}
.at_out li{ list-style-type:none !important; font-size:16px; line-height:1.2; font-weight: bold; margin-left: 0 !important; margin-bottom: 20px !important;}
.at_out li a{ text-decoration:underline; color:rgb(0, 102, 204); list-style-type:none;}
.pc_none{ display:none;}
.sp_none{ display:block;}
api「てめー、そんなことすんじゃねーよExceptionスローするぞオラァ」
って言われるから後はお前の好きなようにするだけ
「さっせんw上のプログラムに返事返しますわw」でもいいし
「>>1の設計クソだな!事前にチェックしてどうにかしろや!俺もExceptionスローしてやるわ!スローするのもお前が書いたんだけどなw」でもいいしな
何いってんだこいつ…
そりゃ当然だろ
お前のプログラムとファイルの間にはどんな邪魔が入るか分からんからな
逆に初心者はヘタに例外処理せん方がええで
ifで判断すりゃいいじゃん
例外投げる必要がない
中間おすすめ記事: 思考ちゃんねる
.mm-ttl{ font-size:14px; margin-bottom: 15px;}
.mm-ttl .Ttl-mil{ font-size:14px !important; color: gray;}
.mm-ttl .Ttl-mil span{ color: rgb(0, 128, 0); font-size: 15px !important; font-weight: bold;}
.at_out ul{-webkit-padding-start: 0; margin: 0 !important; padding: 0;}
.at_out li{ list-style-type:none !important; font-size:16px; line-height:1.2; font-weight: bold; margin-left: 0 !important; margin-bottom: 20px !important;}
.at_out li a{ text-decoration:underline; color:rgb(0, 102, 204); list-style-type:none;}
.pc_none{ display:none;}
.sp_none{ display:block;}
ifよりtry catchの方がいいんじゃないの?
こういうときってifなの?
わからないならわかる方法で実装しろ
そもそもその程度ならエラー処理するまでもない
そんなの強制終了する必要が無いんだから例外処理なんて必要がないだろ
何か間違ってる
文字列をpreaseIntしようとして例外吐かれてるんだろ
これ
内部で受け取った文字列をintへ変換してる
このときってif使うのが正解なのか?
まず入力規則に沿ってるかどうかifで判定しろ
それから変換
それでも取り除けないエラーをtry catchするんだよ
tryparseシラねぇのなら
いつものc#じゃないのか…
例外処理ってのはプログラムで対応できない問題に対して強制終了することだぞ
なにか勘違いしてんじゃん
この場合はif使うのか?
lf (文字列が数字であればってこと?)
でもテキストボックスは数字だけどテキスト(文字として拾う可能性があるのでは?)
想定しないエラー、続行不可能なエラーの時
用意された関数か、正規表現でチェックするのはif
想定外のエラーをtryで拾う
1001: 思考ちゃんねる
.ninki{ clear:both; margin-bottom: 15px;}
.mm-ttl{ font-size:14px;}
.mm-ttl .Ttl-mil{ font-size:15px !important; color: gray;}
.mm-ttl .Ttl-mil span{ color: rgb(0 128 0); font-size: 15px !important; font-weight: bold;}
.at_out ul{-webkit-padding-start: 0; margin: 0 !important; padding: 0;}
.at_out li{ list-style-type:none !important; font-size:16px; line-height:1.2; font-weight: bold; margin-left: 0 !important; margin-bottom: 20px !important;}
.at_out li a{ text-decoration:underline; color:rgb(0 102 204); list-style-type:none;}
.pc_none{ display:none;}
.sp_none{ display:block;}
Source: mindhack
プログラミング初心者あるある