I have the current class in my program.cs
class valor
{
private static double valuee;
public static double Valor
{
get { return valuee; }
set { valuee = value; }
}
}
And I want to use the set accessor from the properties.
Here's my form.cs:
private void dValor_TextChanged(object sender, EventArgs e)
{
Double valor = Convert.ToDouble(dValor.Text);
}
I want to get the .text from the TextBox and then store it in the class valor
from the program.cs
What's the best way to make the access to the valor
class?
Create a new instance of the valor
in your private void dValor_TextChanged
method or in the file that method resides depending on the access you want.
valor myValor = new valor();
Then you should simply be able to set that value to your myValor
object.
myValor.Valor = Convert.ToDouble(dValor.Text);
And as said in a comment in reply to your question your valor class should be public.
public class valor
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.