C
C#2mo ago
human being

IsAllDigits

How to deal with that
No description
56 Replies
ACiDCA7
ACiDCA72mo ago
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
human being
human being2mo ago
Can u get me an example for it I'm a beginner
ACiDCA7
ACiDCA72mo ago
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.
human being
human being2mo ago
It's in the program guys
Blank
Blank2mo ago
You can either use int.TryParse or define your own IsAllDigits method
Blank
Blank2mo ago
No description
Blank
Blank2mo ago
Just write this code in visual studio
human being
human being2mo ago
I did that
Blank
Blank2mo ago
Where is it? I don't see it in your screenshot
human being
human being2mo ago
Give me sec
Blank
Blank2mo ago
alr
Somgör from Human Resources
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
Blank
Blank2mo ago
for a beginner, lets assume they are defining the method in the Program class
Somgör from Human Resources
Calling it directly is only possible from the same class But they are not on the screenshot So I assume it's somewhere else
Blank
Blank2mo ago
Ye
human being
human being2mo ago
No description
human being
human being2mo ago
No description
Blank
Blank2mo ago
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 project
human being
human being2mo ago
Idk how to And thx for u I really appreciate it
Blank
Blank2mo ago
Can you tell me what you did after reading the book (in visual studio)?
human being
human being2mo ago
I didn't finish the book yet I'm learning
Blank
Blank2mo ago
I mean the page
human being
human being2mo ago
I will send u the section Okay
Blank
Blank2mo ago
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 class
human being
human being2mo ago
On the function that I'm working on right
Blank
Blank2mo ago
yes
human being
human being2mo ago
It worked 😅
Blank
Blank2mo ago
Nice
human being
human being2mo ago
No description
Blank
Blank2mo ago
uh
human being
human being2mo ago
But there is no output Give me sec I will try to do something
Monsieur Wholesome
Can you take screenshots instead of taking a phone picture of a screen of code?
Blank
Blank2mo ago
you don't have to put the IsAllDigits inside Main
human being
human being2mo ago
No description
Blank
Blank2mo ago
@human being do it like this:
public static void Main(string[] args)
{
// Your code...
}

public static bool IsAllDigits(string raw)
{
// Your code..
}
public static void Main(string[] args)
{
// Your code...
}

public static bool IsAllDigits(string raw)
{
// Your code..
}
human being
human being2mo ago
where will i put the code
Blank
Blank2mo ago
Where I have written "Your code" You put this in the main function
human being
human being2mo ago
k
Blank
Blank2mo ago
And this in the other function
human being
human being2mo ago
do u mean to copy the code or what
leowest
leowest2mo ago
I strongly suggest u check these when u can https://learn.microsoft.com/en-us/shows/csharp-fundamentals-for-absolute-beginners/ specially scope chapter
Blank
Blank2mo ago
Like you write the code inside the functions
human being
human being2mo ago
yeah is this good
human being
human being2mo ago
No description
Blank
Blank2mo ago
yes
human being
human being2mo ago
Thank you very very much I appreciate your help
Blank
Blank2mo ago
you have written one line wrong here according to the book, its if (s[index] == '-' && index == 0) continue;
human being
human being2mo ago
Yeah I see Idk how to thank u
Blank
Blank2mo ago
ah dont worry we are here to help
leowest
leowest2mo ago
if you do CTRL+K+D it will auto format your code for u align lines etc
leowest
leowest2mo ago
No description
Blank
Blank2mo ago
Below you can see what I mean (warning: spoonfeed content ahead)
human being
human being2mo ago
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
Blank
Blank2mo ago
Don't worry, just try to focus on the basics. Its easy to implement things afterwards
human being
human being2mo ago
yea thx man goodbye❣️