错误:方法参数必须括在括号中 [英] error: method arguments must be enclosed in parentheses

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

问题描述

我有阅读所有行的代码

    while  sr.Peek()> =  0  
line = sr.ReadLine()
循环



但我在第一行收到错误,说:方法参数必须括在括号中

解决方案

试试这个

  string  fileText = < span class =code-keyword> string  .Empty; 
使用(StreamReader sr = new StreamReader( YoufilePathHere))
{
fileText = sr.ReadToEnd(); // 它会读取文件的所有文字。
}







VB



< pre lang =vb> Dim fileText As String = 字符串 .Empty
使用 sr 正如 StreamReader( YoufilePathHere
' 它将读取文件的所有文本。
fileText = sr.ReadToEnd()
结束 使用


问题不在你显示的代码片段中:这是完全有效的,并且编译没有问题。



在此之前查看代码,很可能是你忘记了某些东西,或者在某个地方留下了虚假的下划线。尝试双击实际的错误消息 - 它可能会带你到真正的问题。



如果没有,我们需要一个更大的代码片段来帮助你!


我是编程的新手,但我认为以下几行正在产生问题。



sr.Peek()> = 0



因为编译器正在考虑> = 0作为sr.Peek()的参数



所以得到函数的结果在某个变量或类似的东西,并且dn把比较运算符放在那个。





问候。



:)


hi, i am having this code for reading all lines

Do While sr.Peek() >= 0
    line = sr.ReadLine() 
Loop 


but i am getting an error on first line which says: method arguments must be enclosed in parentheses

解决方案

Try this

string fileText = string.Empty;
                using (StreamReader sr = new StreamReader("YoufilePathHere"))
                {
                    fileText = sr.ReadToEnd();      //it will read all text of file.
                }




in VB

Dim fileText As String = String.Empty
Using sr As New StreamReader("YoufilePathHere")
		'it will read all text of file.
	fileText = sr.ReadToEnd()
End Using


The problem is not in the code fragment you show: That is perfectly valid and will compile without problems.

Look at the code immediately before this, It is likely that you have forgotten something, or left a spurious underline somewhere. Try double clicking on the actual error message - it may take you to the line with the real problem.

If not, we would need a larger code fragment to help!


I am new to programming , but I think the following line is creating problem.

sr.Peek() >= 0

as compiler is considering >=0 as argument of "sr.Peek()"

so get the result of function in some variable or like something, and dn put comparison operator on that.


Regards.

:)


这篇关于错误:方法参数必须括在括号中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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