Click here to Skip to main content
15,887,936 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to Convert Amibroker AFL to Dll setup file with License Manager Pin
Pete O'Hanlon9-Jun-16 2:15
mvePete O'Hanlon9-Jun-16 2:15 
GeneralRe: How to Convert Amibroker AFL to Dll setup file with License Manager Pin
Member 125746279-Jun-16 2:17
Member 125746279-Jun-16 2:17 
GeneralRe: How to Convert Amibroker AFL to Dll setup file with License Manager Pin
Pete O'Hanlon9-Jun-16 2:33
mvePete O'Hanlon9-Jun-16 2:33 
GeneralRe: How to Convert Amibroker AFL to Dll setup file with License Manager Pin
Eddy Vluggen10-Jun-16 11:55
professionalEddy Vluggen10-Jun-16 11:55 
QuestionItem deleted in control even already assign to another variable. Pin
Le@rner8-Jun-16 21:11
Le@rner8-Jun-16 21:11 
AnswerRe: Item deleted in control even already assign to another variable. Pin
Pete O'Hanlon8-Jun-16 22:27
mvePete O'Hanlon8-Jun-16 22:27 
AnswerRe: Item deleted in control even already assign to another variable. Pin
Richard MacCutchan8-Jun-16 22:43
mveRichard MacCutchan8-Jun-16 22:43 
AnswerRe: Item deleted in control even already assign to another variable. Pin
OriginalGriff8-Jun-16 22:47
mveOriginalGriff8-Jun-16 22:47 
It's a little hard to get your head round, but it's pretty simple when you do.
So let's ignore it for a moment, and talk about cars.
Suppose you get in your car and put your mobile in the glovebox.
If you later get in my car and open the glove box, will your mobile be there?

No - it's in your car, not mine: they are separate instances of the generic class "Car", and you do not expect items to magically move between them!

But...suppose my wife an I both share a car. If she puts her mobile in the glove box of "her car" and I later look in the glove box of "my car" what will I see? Her mobile of course! Why? Because "her car" and "my car" are different references to the same actual vehicle - the same instance of the generic class "Car".

In computer terms, the two scenarios are like this:
C#
Car yourCar = new Car("Blue");
Car myCar = new Car("Red");
yourCar.GloveBox.Add(yourMobile);
if (myCar.GloveBox.Contains(yourMobile))
   throw new UniverseException("How did that happen?");

And
C#
Car myCar = new Car("Red");
Car herCar = myCar;
herCar.GloveBox.Add(herMobile);
if (myCar.GloveBox.Contains(herMobile))
   Console.WriteLine("Found it dear! You left it in the glovebox again!");

You are doing the same thing with your class:
C#
MyPanel panel1 = new MyPanel();
MyPanel temp = panel1;  // same instance!
temp.Controls.Remove(button1); // Removes it from the one and only instance of the panel you have created
This is because classes are what is called a Reference Type: a variable of the class doesn't contain the actual class, but a reference to it in the same way that "my car" doesn't contain the actual car, but refers to a specific vehicle.
Integers and so forth are Value Types: they do contain the actual value so when you say
C#
int i = 666;
int j = i;
j = j / 2;
Console.WriteLine("{0}:{1}", i, j);
you will get "666:333" - and any other result would make maths very difficult to do!
If you embed the integer in a class:
C#
public class MyClass
   {
   public int i;
   }
...
   MyClass m1 = new MyClass;
   m1.i = 666;
   MyClass m2 = m1;
   m2.i = m2.i / 2;
   Console.WriteLine("{0}:{1}", m1.i, m2.i);
you will get "333:333" because the references m1 and m2 are "talking about" the same instance of MyClass.
Some of this may make it easier to understand: Using struct and class - what's that all about?[^] - but it gets a bit advanced from the section "It's never that easy, is it?" so you might want to stop there for the moment!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

AnswerRe: Item deleted in control even already assign to another variable. Pin
BillWoodruff8-Jun-16 23:05
professionalBillWoodruff8-Jun-16 23:05 
GeneralRe: Item deleted in control even already assign to another variable. Pin
Le@rner9-Jun-16 2:40
Le@rner9-Jun-16 2:40 
QuestionIgnore Error Pin
sunsher8-Jun-16 20:05
sunsher8-Jun-16 20:05 
AnswerRe: Ignore Error Pin
OriginalGriff8-Jun-16 20:30
mveOriginalGriff8-Jun-16 20:30 
GeneralRe: Ignore Error Pin
sunsher12-Jun-16 12:42
sunsher12-Jun-16 12:42 
GeneralRe: Ignore Error Pin
OriginalGriff12-Jun-16 21:05
mveOriginalGriff12-Jun-16 21:05 
QuestionSystem.NullReferenceException Pin
sunsher8-Jun-16 12:48
sunsher8-Jun-16 12:48 
AnswerRe: System.NullReferenceException Pin
Matt T Heffron8-Jun-16 13:56
professionalMatt T Heffron8-Jun-16 13:56 
AnswerRe: System.NullReferenceException Pin
BillWoodruff8-Jun-16 13:58
professionalBillWoodruff8-Jun-16 13:58 
GeneralRe: System.NullReferenceException Pin
sunsher8-Jun-16 18:57
sunsher8-Jun-16 18:57 
GeneralRe: System.NullReferenceException Pin
sunsher8-Jun-16 19:10
sunsher8-Jun-16 19:10 
GeneralRe: System.NullReferenceException Pin
Pete O'Hanlon8-Jun-16 21:15
mvePete O'Hanlon8-Jun-16 21:15 
GeneralRe: System.NullReferenceException Pin
BillWoodruff8-Jun-16 21:54
professionalBillWoodruff8-Jun-16 21:54 
Questionpassword policy using c# Pin
forest4ever7-Jun-16 20:33
forest4ever7-Jun-16 20:33 
AnswerRe: password policy using c# Pin
Garth J Lancaster7-Jun-16 20:44
professionalGarth J Lancaster7-Jun-16 20:44 
AnswerRe: password policy using c# Pin
Mycroft Holmes7-Jun-16 22:19
professionalMycroft Holmes7-Jun-16 22:19 
AnswerRe: password policy using c# Pin
OriginalGriff7-Jun-16 22:28
mveOriginalGriff7-Jun-16 22:28 

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.