+ 1
Can you help ? What is there wrong?
13 Answers
+ 2
Yes you can.
https://code.sololearn.com/ce9xvKovazSN
I did almost nothing to your metod.
Just added a foreach- loop in Main method and the code is working.
ok and removed some of my debug-statements
ok
(0 < j) should be (0 <= j)
+ 2
I like to help you but you need to answer my question.
Is "54.97.94.64" valid input ?
+ 2
Thanks. Read my comments below.
Change this line : foreach (var word in ipv4)
ipv4 is the orginal not splitted string, this foreach loop loops through every single character of the string
to : foreach (var word in words)
Change this line :
if (word.GetType() == typeof(int) && (0 < i) && (i < 256))
to :
i.GetType() == typeof(int) && (0 < i) && (i < 256))
word is of type var,
but when initialized in the " foreach (var word in words)"
words is of type string[] so word is a string
Ultimately change the line to this
int j;
if (int.TryParse(word, out j) && (0 < i) && (i < 256)) // but you are looking for this
TryParse tries to convert the first parameter to a int. If it does not succeed TryParse returns false. If true the converted value is set in the second parameter ("j")
https://www.dotnetperls.com/parse
https://code.sololearn.com/cAMBE9btPL5B
You did a good job, just made some beginner mistakes.
+ 2
thenk you ,you help my much.
+ 1
int i=Convert.Toint(word );
should be
int i=Convert.ToInt32(word );
And I did comment out
Console.ReadKey();
Because you do not need it in the playground.
+ 1
Metod returns the value false
so the output that is printed is false
Please elaborate more what is the output you expected ?
+ 1
i wait you ,help please.
https://code.sololearn.com/cg5S9E2zgyAC/?ref=app
+ 1
yes
+ 1
your are welcome
+ 1
realy i wont write thishttps://www.sololearn.com/learn/4601/?ref=app
0
I chenged but no result.
0
Should the code return True ?
Are you getting "No output" as result ?
0
No,i get false.