Click here to Skip to main content
15,902,801 members
Home / Discussions / C#
   

C#

 
QuestionVery basic beginners confusion over public properties [modified] Pin
Daley8330-Jun-10 5:50
Daley8330-Jun-10 5:50 
AnswerRe: Very basic beginners confusion over public properties Pin
Ravi Bhavnani30-Jun-10 6:04
professionalRavi Bhavnani30-Jun-10 6:04 
GeneralRe: Very basic beginners confusion over public properties Pin
Daley8330-Jun-10 6:08
Daley8330-Jun-10 6:08 
GeneralRe: Very basic beginners confusion over public properties Pin
Ravi Bhavnani30-Jun-10 6:10
professionalRavi Bhavnani30-Jun-10 6:10 
AnswerRe: Very basic beginners confusion over public properties Pin
harold aptroot30-Jun-10 6:05
harold aptroot30-Jun-10 6:05 
GeneralRe: Very basic beginners confusion over public properties Pin
Daley8330-Jun-10 6:10
Daley8330-Jun-10 6:10 
GeneralRe: Very basic beginners confusion over public properties Pin
harold aptroot30-Jun-10 6:11
harold aptroot30-Jun-10 6:11 
AnswerRe: Very basic beginners confusion over public properties Pin
Keith Barrow30-Jun-10 6:11
professionalKeith Barrow30-Jun-10 6:11 
Can you edit you post and put the code between it in <pre> </pre> tags please, this will make it more readable:

public void Start(object sender, EventArgs e)
{
  Apple a1 = new Apple();
  a1.runApple();
  txtOuput.Text = a1.Name;
}


The problem is that the RunApple method creates a new instance of Apple, change it to this instead:

public void runApple()
{
   Name = "Apple";
}


This sets the name property of the instance of Apple it is running in.


A Few other points, fieldnames should start in lowercase e.g. string _name and method names should start uppercase e.g. RunApple. Finally, RunApple isn't a good name, Initialise Might be better, or better yet move Name = "Apple"; into the Apple constructor.
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.

GeneralRe: Very basic beginners confusion over public properties Pin
Daley8330-Jun-10 6:20
Daley8330-Jun-10 6:20 
AnswerRe: Very basic beginners confusion over public properties Pin
Ennis Ray Lynch, Jr.30-Jun-10 6:12
Ennis Ray Lynch, Jr.30-Jun-10 6:12 
GeneralRe: Very basic beginners confusion over public properties Pin
harold aptroot30-Jun-10 6:14
harold aptroot30-Jun-10 6:14 
GeneralRe: Very basic beginners confusion over public properties Pin
Daley8330-Jun-10 6:17
Daley8330-Jun-10 6:17 
GeneralRe: Very basic beginners confusion over public properties Pin
Ennis Ray Lynch, Jr.30-Jun-10 6:28
Ennis Ray Lynch, Jr.30-Jun-10 6:28 
QuestionHow to show tooltip on the button Pin
undynamicmagic30-Jun-10 4:52
undynamicmagic30-Jun-10 4:52 
AnswerRe: How to show tooltip on the button Pin
Peace ON30-Jun-10 4:58
Peace ON30-Jun-10 4:58 
GeneralRe: How to show tooltip on the button Pin
undynamicmagic30-Jun-10 5:52
undynamicmagic30-Jun-10 5:52 
QuestionUsing a Chart Control in Vs 2010 [modified] Pin
It_tech30-Jun-10 4:33
It_tech30-Jun-10 4:33 
QuestionCorrect marshalling? C# callback from C++ DLL Pin
ProfAndyZulu30-Jun-10 3:14
ProfAndyZulu30-Jun-10 3:14 
AnswerRe: Correct marshalling? C# callback from C++ DLL Pin
David Knechtges30-Jun-10 5:07
David Knechtges30-Jun-10 5:07 
Questionstd::map<> in C# Pin
raju_shiva30-Jun-10 1:50
raju_shiva30-Jun-10 1:50 
AnswerRe: std::map in C# Pin
Łukasz Nowakowski30-Jun-10 1:56
Łukasz Nowakowski30-Jun-10 1:56 
AnswerRe: std::map in C# Pin
Pete O'Hanlon30-Jun-10 3:00
mvePete O'Hanlon30-Jun-10 3:00 
AnswerRe: std::map in C# Pin
Laxman Auti30-Jun-10 5:25
Laxman Auti30-Jun-10 5:25 
GeneralRe: std::map in C# Pin
raju_shiva30-Jun-10 20:21
raju_shiva30-Jun-10 20:21 
GeneralRe: std::map in C# Pin
Laxman Auti30-Jun-10 22:46
Laxman Auti30-Jun-10 22:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.