© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
7 replies
Livid

✅ try catch

hey for example (i know tryparse exists)
var str1 = "123"
var str2 = "0ab"
var str3 = "65_"

var int1 = Convert.ToInt32(str1)
var int2 = Convert.ToInt32(str2)
var int3 = Convert.ToInt32(str3)
var str1 = "123"
var str2 = "0ab"
var str3 = "65_"

var int1 = Convert.ToInt32(str1)
var int2 = Convert.ToInt32(str2)
var int3 = Convert.ToInt32(str3)

is there a way to seperate the try / catch in a way that if int1 is valid (but int2 and int3 not) that int1 is still set
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Try catch exception.
C#CC# / help
13mo ago
✅ Why doesn't this try catch, catch exception.
C#CC# / help
10mo ago
✅ Issue with try/catch block
C#CC# / help
10mo ago