C
C#7mo ago
Ziad Waleed

IsAllDigits

How to deal with that
No description
56 Replies
ACiDCA7
ACiDCA77mo 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
Ziad Waleed
Ziad WaleedOP7mo ago
Can u get me an example for it I'm a beginner
ACiDCA7
ACiDCA77mo 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.
Ziad Waleed
Ziad WaleedOP7mo ago
It's in the program guys
Blank
Blank7mo ago
You can either use int.TryParse or define your own IsAllDigits method
Blank
Blank7mo ago
No description
Blank
Blank7mo ago
Just write this code in visual studio
Ziad Waleed
Ziad WaleedOP7mo ago
I did that
Blank
Blank7mo ago
Where is it? I don't see it in your screenshot
Ziad Waleed
Ziad WaleedOP7mo ago
Give me sec
Blank
Blank7mo ago
alr
The Fog 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
Blank7mo ago
for a beginner, lets assume they are defining the method in the Program class
The Fog 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
Blank7mo ago
Ye
Ziad Waleed
Ziad WaleedOP7mo ago
No description
Ziad Waleed
Ziad WaleedOP7mo ago
No description
Blank
Blank7mo 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
Ziad Waleed
Ziad WaleedOP7mo ago
Idk how to And thx for u I really appreciate it
Blank
Blank7mo ago
Can you tell me what you did after reading the book (in visual studio)?
Ziad Waleed
Ziad WaleedOP7mo ago
I didn't finish the book yet I'm learning
Blank
Blank7mo ago
I mean the page
Ziad Waleed
Ziad WaleedOP7mo ago
I will send u the section Okay
Blank
Blank7mo 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
Ziad Waleed
Ziad WaleedOP7mo ago
On the function that I'm working on right
Blank
Blank7mo ago
yes
Ziad Waleed
Ziad WaleedOP7mo ago
It worked 😅
Blank
Blank7mo ago
Nice
Ziad Waleed
Ziad WaleedOP7mo ago
No description
Blank
Blank7mo ago
uh
Ziad Waleed
Ziad WaleedOP7mo 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
Blank7mo ago
you don't have to put the IsAllDigits inside Main
Ziad Waleed
Ziad WaleedOP7mo ago
No description
Blank
Blank7mo 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..
}
Ziad Waleed
Ziad WaleedOP7mo ago
where will i put the code
Blank
Blank7mo ago
Where I have written "Your code" You put this in the main function
Ziad Waleed
Ziad WaleedOP7mo ago
k
Blank
Blank7mo ago
And this in the other function
Ziad Waleed
Ziad WaleedOP7mo ago
do u mean to copy the code or what
leowest
leowest7mo 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
Blank7mo ago
Like you write the code inside the functions
Ziad Waleed
Ziad WaleedOP7mo ago
yeah is this good
Ziad Waleed
Ziad WaleedOP7mo ago
No description
Blank
Blank7mo ago
yes
Ziad Waleed
Ziad WaleedOP7mo ago
Thank you very very much I appreciate your help
Blank
Blank7mo ago
you have written one line wrong here according to the book, its if (s[index] == '-' && index == 0) continue;
Ziad Waleed
Ziad WaleedOP7mo ago
Yeah I see Idk how to thank u
Blank
Blank7mo ago
ah dont worry we are here to help
leowest
leowest7mo ago
if you do CTRL+K+D it will auto format your code for u align lines etc
leowest
leowest7mo ago
No description
Blank
Blank7mo ago
Below you can see what I mean (warning: spoonfeed content ahead)
Ziad Waleed
Ziad WaleedOP7mo 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
Blank7mo ago
Don't worry, just try to focus on the basics. Its easy to implement things afterwards
Ziad Waleed
Ziad WaleedOP7mo ago
yea thx man goodbye❣️
Want results from more Discord servers?
Add your server