56 Replies
just use tryparse
and you can save yourself the check with alldigits
because if it cannot be parsed you will know that its not a number
Can u get me an example for it
I'm a beginner
Int32.TryParse Method (System)
Converts the string representation of a number to its 32-bit signed integer equivalent. A return value indicates whether the operation succeeded.
It's in the program guys
You can either use
int.TryParse
or define your own IsAllDigits
methodJust write this code in visual studio
I did that
Where is it?
I don't see it in your screenshot
Give me sec
alr
You need to define the class you're pulling the function from too
If it exists in your project you need to reference namespace and class
for a beginner, lets assume they are defining the method in the
Program
classCalling it directly is only possible from the same class
But they are not on the screenshot
So I assume it's somewhere else
Ye
Okay I get the problem, you defined the
IsAllDigits
method in a totally different project
You need to write both the methods in the same projectIdk how to
And thx for u I really appreciate it
Can you tell me what you did after reading the book (in visual studio)?
I didn't finish the book yet
I'm learning
I mean the page
I will send u the section
Okay
So what you have to do is write the
IsAllDigits
function like you did in the above image.
Then write the Main
function in the same classOn the function that I'm working on right
yes
It worked 😅
Nice
uh
But there is no output
Give me sec I will try to do something
Can you take screenshots instead of taking a phone picture of a screen of code?
you don't have to put the
IsAllDigits
inside Main
@human being do it like this:
where will i put the code
Where I have written "Your code"
You put this in the main function
k
And this in the other function
do u mean to copy the code or what
I strongly suggest u check these when u can https://learn.microsoft.com/en-us/shows/csharp-fundamentals-for-absolute-beginners/
specially scope chapter
Like you write the code inside the functions
yeah is this good
yes
Thank you very very much
I appreciate your help
you have written one line wrong here
according to the book, its
if (s[index] == '-' && index == 0) continue;
Yeah I see
Idk how to thank u
ah dont worry
we are here to help
if you do CTRL+K+D it will auto format your code for u
align lines etc
Below you can see what I mean (warning: spoonfeed content ahead)
yeah i get what was u talking about
man u helped me so so much
I haven't read the class chapter u know maybe that my problem
I'm in chaper 3, the class chapter is on 6
Don't worry, just try to focus on the basics. Its easy to implement things afterwards
yea thx man goodbye❣️