-
July 12th, 2012, 10:50 PM
#1
How to turn this code into properties?
public class Answer
{
public Answer(string p, bool c)
{
Prompt = p;
Correct = c;
}
public string Prompt;
public bool Correct;
}
-
July 13th, 2012, 12:14 AM
#2
Re: How to turn this code into properties?
This is VC++ board. You are posting in the wrong forum again. This is right place for C# questions.
-
July 13th, 2012, 08:12 AM
#3
Re: How to turn this code into properties?
-
July 15th, 2012, 02:51 PM
#4
Re: How to turn this code into properties?
Two ways.
Using 'regular' properties:
Code:
public class Answer
{
public Answer(string p, bool c)
{
Prompt = p;
Correct = c;
}
public string Prompt
{
get { return _prompt; }
private set { _prompt = value; }
}
public bool Correct;
{
get { return _correct; }
private set { _correct = value; }
}
private string _prompt;
private string _correct;
}
Using autoproperties:
Code:
public class Answer
{
public Answer(string p, bool c)
{
Prompt = p;
Correct = c;
}
public string Prompt { get; private set; }
public bool Correct { get; private set; }
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|