Click here to Skip to main content
15,914,014 members
Home / Discussions / C#
   

C#

 
GeneralRe: About IE context Pin
Jason Xie4-Nov-04 15:23
Jason Xie4-Nov-04 15:23 
GeneralRe: About IE context Pin
Nick Parker4-Nov-04 16:25
protectorNick Parker4-Nov-04 16:25 
GeneralRe: About IE context Pin
Jason Xie4-Nov-04 16:32
Jason Xie4-Nov-04 16:32 
GeneralRe: About IE context Pin
Nick Parker4-Nov-04 16:54
protectorNick Parker4-Nov-04 16:54 
GeneralRe: About IE context Pin
Jason Xie4-Nov-04 17:01
Jason Xie4-Nov-04 17:01 
GeneralRe: About IE context Pin
IronSnake5-Nov-04 9:36
IronSnake5-Nov-04 9:36 
GeneralRe: About IE context Pin
Jason Xie5-Nov-04 13:42
Jason Xie5-Nov-04 13:42 
Generalstring methods Pin
John L. DeVito4-Nov-04 14:02
professionalJohn L. DeVito4-Nov-04 14:02 
Greetings all,

Comming from a unix/C background here I'm attempting to get the length of a string entered from the user. Here is some code...

namespace _250_question_1
{
class HowEasy
{
public int pointVal(string input)
{
int word_count = 0;

for(int x = 0; x <= strlen(input); x++)
if(input[x] == " ") word_count++;

if(word_count <= 3) return 250;
if((word_count == 4) ||
(word_count == 5)) return 500;
if(word_count >= 6) return 1000;
}

static void Main(string[] args)
{
string user_input;

Console.WriteLine("Please enter a string:");
Console.ReadLine(user_input);
pointVal(user_input);
}
}
}

The algorithm is how I would do it in C, However in C# I can't compare an array element (string[x]) for equality. Not only that, I would normally use strlen() in for() and apparently the standard C library isn't used. Could anyone rewrite this in C# so I can see what's going on, or at least give me some hints?

Thanks all!!

kha0s

"There are 10 types of people in this world; Those that know binary and those that do not."
GeneralRe: string methods Pin
Christian Graus4-Nov-04 14:18
protectorChristian Graus4-Nov-04 14:18 
GeneralRe: string methods Pin
Nick Parker4-Nov-04 15:11
protectorNick Parker4-Nov-04 15:11 
GeneralRe: string methods Pin
Grimolfr5-Nov-04 10:08
Grimolfr5-Nov-04 10:08 
Generalproblem in debugging,when theres DLLs Pin
gijoebijoe4-Nov-04 12:18
gijoebijoe4-Nov-04 12:18 
GeneralRe: problem in debugging,when theres DLLs Pin
sreejith ss nair4-Nov-04 17:16
sreejith ss nair4-Nov-04 17:16 
GeneralRe: problem in debugging,when theres DLLs Pin
turbochimp5-Nov-04 8:50
turbochimp5-Nov-04 8:50 
GeneralGantt & Calendar control Pin
Jordi Corominas4-Nov-04 10:44
Jordi Corominas4-Nov-04 10:44 
GeneralRe: Gantt &amp; Calendar control Pin
sreejith ss nair4-Nov-04 17:21
sreejith ss nair4-Nov-04 17:21 
GeneralRe: Gantt &amp; Calendar control Pin
Jordi Corominas4-Nov-04 21:06
Jordi Corominas4-Nov-04 21:06 
GeneralRe: Gantt &amp; Calendar control Pin
sreejith ss nair4-Nov-04 21:25
sreejith ss nair4-Nov-04 21:25 
GeneralRe: Gantt &amp; Calendar control Pin
Stefan Troschuetz4-Nov-04 21:34
Stefan Troschuetz4-Nov-04 21:34 
GeneralRe: Gantt & Calendar control Pin
Jordi Corominas4-Nov-04 21:47
Jordi Corominas4-Nov-04 21:47 
GeneralRe: Gantt &amp; Calendar control Pin
Anonymous5-Nov-04 12:50
Anonymous5-Nov-04 12:50 
GeneralFormat specifier Pin
Luis Alonso Ramos4-Nov-04 10:08
Luis Alonso Ramos4-Nov-04 10:08 
GeneralRe: Format specifier Pin
Stefan Troschuetz4-Nov-04 23:12
Stefan Troschuetz4-Nov-04 23:12 
GeneralRe: Format specifier - that won't do it. Pin
Luis Alonso Ramos5-Nov-04 5:33
Luis Alonso Ramos5-Nov-04 5:33 
GeneralOpenFileDialog - multiple extensions on filter Pin
benjymous4-Nov-04 10:08
benjymous4-Nov-04 10:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.