StringSplitOptions.RemoveEmptyEntries中的错误 [英] Error in StringSplitOptions.RemoveEmptyEntries

查看:82
本文介绍了StringSplitOptions.RemoveEmptyEntries中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hellow
调试以下方法时,我在StringSplitOptions.RemoveEmptyEntries中遇到了奇怪的错误,调试器写道我需要新的(用于内存)
我需要您的评论
这是整个代码(小尺寸代码)

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]);
       }

推荐答案

该行是正确的,应该可以,但是ssFeedo的初始化是完全多余的;并且初始值将被简单地丢弃:String.Split创建一个全新的对象.

您使用了不正确的术语,这可能会损害您对继续使用它的帖子的理解.您所说的字体"实际上是一个字符".字体与字符串和字符串处理完全无关.

如果有任何疑问,则需要使用调试器.实际上,每次都应在询问此类问题之前使用调试器.

—SA
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


您是对的,它是一个字符而不是一种字体,但是如果此空格字符是用阿拉伯字体写的,我的意思是在上面的输入文本文件中字符空间{''}}也应使用阿拉伯语

您写的ssFeedo完全多余;
您可能是指以下行
string [] ssFeedo =新字符串[6];
我应该使用

字符串[] ssFeedo;

你能纠正一下吗?
如果没有,请告知我确切的答案
有人写了
我认为调试器可能不会发出这样的消息

实际上,我在我的大型程序中收到了此消息(可能是类似的消息).如果我在此处发布,则没人愿意看它
我需要确切的答案,请
谢谢
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


这篇关于StringSplitOptions.RemoveEmptyEntries中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆