Click here to Skip to main content
12,299,517 members (57,259 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# C#4.0
hellow
debuging the following method i got strange error in StringSplitOptions.RemoveEmptyEntries, the debugger wrote i need new (for memory)
i need your comment
this is the whole code(small size code)
        public static int TestStringSplitOptions()
        {
            string buff;
            string[] ssFeedo = new string[6];
            int day,month;
            /*
            //My input file has only 2 line and Start from next line
            MyDate.txt
            20 07
            */
            //assume MyhFile is defined correctly somewhere else
            buff = MyhFile.ReadLine();//buff="MyDate.txt"
            
            buff = MyhFile.ReadLine();//buff="20 07"
           //MessageBox.Show(buff);
// the font between quots are english space i mean {' '} in next line
ssFeedo = buff.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);//<--not certain about this
            day = int.Parse(ssFeedo[0]);
            month = int.Parse(ssFeedo[1]);
       }
Posted 16-Nov-12 7:02am
Edited 16-Nov-12 7:06am
v5
Comments
ProgramFOX 16-Nov-12 13:11pm
   
What I'll tell you here, isn't an answer, but another thing.
First you set buff to MyhFile.ReadLine();
Then, in another line, you set buff to MyhFile.ReadLine();
But, then you the value of buff is only the second line.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

The line is correct, should work, but initialization of ssFeedo is totally redundant; and the initial value will simply be discarded: String.Split creates a brand new object.

You use incorrect terminology which can compromise understanding of your post it you keep using it. What you call "font" is actually a "characters". Fonts have nothing to do with strings and string processing at all.

If you have any concerns, you need to use the debugger. Actually, you should use a debugger before asking such questions, every time.

—SA
  Permalink  
v2
Comments
ProgramFOX 16-Nov-12 13:27pm
   
He used the debugger.
In the question:
the debugger wrote i need new (for memory)
Sergey Alexandrovich Kryukov 16-Nov-12 13:30pm
   
In my view, not quite :-) And I don't understand this phrase. I don't thing a debugger could possibly issue such message; I think this is the OP's phrasing based on some illusionary observations -- such things happen all the time; I don't understand why would you repeat these words...
--SA
ProgramFOX 16-Nov-12 13:32pm
   
Ok.
Anyway, a 5!
Sergey Alexandrovich Kryukov 16-Nov-12 14:55pm
   
Than you again.
--SA
ProgramFOX 16-Nov-12 13:45pm
   
Comment from the OP, posted as a non-answer (Solution 2):
you wrote ssFeedo is totally redundant;
you may meant the following line
string[] ssFeedo = new string[6];

could you please correct that,
if not this line let me know the exact answer
someone wrote
I don't thing a debugger could possibly issue such message

actualy i got this answer for my big program .if i posted here no one is willing to look at it
i need the exact answer please
thanks
Sergey Alexandrovich Kryukov 16-Nov-12 14:54pm
   
Khalid,

Yes, you understood it correctly. Remove initialization "= new string[6]" and update the split call per the code in my answer.
May be there are other problems, but do this first. (First of all, I don't know the content of downloaded string; don't know if it was downloaded correctly, etc.) If something else is wrong, don't hesitate to ask follow-up question. If it works, please accept the answer formally (green button) -- thanks.

--SA
Sergey Alexandrovich Kryukov 16-Nov-12 14:55pm
   
Thank you, ProgramFOX, I replied.
--SA
Khalid Sabtan 16-Nov-12 15:33pm
   
hellow Sergey

i have tried string[] ssFeedo; but still having error so i changed my program to this StrLeft = buff.Split(' ')[0].Trim();

StrRight = buff.Split(' ')[1].Trim();

day = int.Parse(StrLeft); month = int.Parse(StrRight);

still getting error,now i am convinced that my error is in

buff = MyhFile.ReadLine();//buff="20 07"

actually MyhFile (Form1.MyhFile)is defined as a public static in form1.cs and created in another file.cs, i did not inform you about MyhFile because i want my question as short as possible ,but the compiler giving me error in somewhere else "this is what it seems to me".your 5 is underway
Sergey Alexandrovich Kryukov 16-Nov-12 15:43pm
   
[Scratched out wrong advice I've written by mistake here... --SA]
Did you check up the content of the loaded string? How do you know that first split part should parse as int?!
Please, post the content of this file.
After all, use the debugger, and do it properly.
--SA
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

you are right it is a character not a font ,but if this space character is written in arabic font i mean in the above input text file the character space {' '} should be in arabic too

you wrote ssFeedo is totally redundant;
you may meant the following line
string[] ssFeedo = new string[6];
should i use

string[] ssFeedo;

could you please correct that,
if not this line let me know the exact answer
someone wrote
I don't thing a debugger could possibly issue such message

actualy i got this message (may be a similar ) for my big program .if i posted here no one is willing to look at it
i need the exact answer please
thanks
  Permalink  
v5
Comments
ProgramFOX 16-Nov-12 13:45pm
   
If you've a comment to a answer, click on the "Have a Question or Comment?" button.
Don't post a comment as an answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160525.2 | Last Updated 16 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100