简体   繁体   中英

How to use label inside my own function C# (windows forms application)

Label and my function在此处输入图片说明

So I've got my Form label and one function I wrote myself. Now inside that function I call label1.Text and It won't pass the compiler. Don't know what I'm doing wrong, can anyone suggest me a solution?

Inside my function在此处输入图片说明

label1.Text="blah blah blah"不是label1.Text("blah blah blah")

You're using Label1.Text as a function which is wrong since Text is a property. The correct way to do it is Label1.Text = "some text" .

You need to change your code to:

Label1.Text = "Your string goes here.";

The Text value of your label is a property , not a method .

To set the text in a label you have to do:

label1.Text="hello world" 

you are instead using it as it were a method call

label1.Text("hello world") //wrong!!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM