Click here to Skip to main content
15,880,608 members
Home / Discussions / C#
   

C#

 
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 
When you declare an instance of the Interface and set it to 'Null, there's nothing "inside" the Interface. I think it would be better in this case if the compiler would refuse to compile that statement.

So, when you try and set the (assume it's the) 'Height property of the Interface instance, it's like you are saying, in effect: "let the Height of nothing be ..."

You need to first create an instance of a Class that inherits from the Interface:
C#
// in NameSpace scope
public interface IDimensions
{
    int Height { set; get; }
}

// in NameSpace scope
public class Dimensions : IDimensions
{
    public int Height { set; get; }

    public Dimensions(int height)
    {
        Height = height;
    }
}

// then create an instance of the Class

// in Form scope: leave off the 'public access modifier if you define the instance in a Method
public Dimensions MyDimensions = new Dimensions(3);

// then you can set the 'Height property at any time

// in some Method or EventHandler
MyDimensions.Height = 12;
If this doesn't clear things up a bit for you, let me know.
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008

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 
QuestionSet window on top from ShellExecute? Pin
kenw2327-Jun-16 11:25
kenw2327-Jun-16 11:25 
AnswerRe: Set window on top from ShellExecute? Pin
Eddy Vluggen7-Jun-16 12:10
professionalEddy Vluggen7-Jun-16 12:10 
AnswerRe: Set window on top from ShellExecute? Pin
BillWoodruff8-Jun-16 7:26
professionalBillWoodruff8-Jun-16 7:26 
QuestionHow can I format a text selection in bold AND italic? Pin
Member 119167356-Jun-16 23:23
Member 119167356-Jun-16 23:23 
AnswerRe: How can I format a text selection in bold AND italic? Pin
OriginalGriff6-Jun-16 23:39
mveOriginalGriff6-Jun-16 23:39 
GeneralRe: How can I format a text selection in bold AND italic? Pin
Member 119167357-Jun-16 0:02
Member 119167357-Jun-16 0:02 
GeneralRe: How can I format a text selection in bold AND italic? Pin
OriginalGriff7-Jun-16 0:20
mveOriginalGriff7-Jun-16 0:20 
GeneralRe: How can I format a text selection in bold AND italic? Pin
Member 119167357-Jun-16 0:23
Member 119167357-Jun-16 0:23 
GeneralRe: How can I format a text selection in bold AND italic? Pin
OriginalGriff7-Jun-16 0:45
mveOriginalGriff7-Jun-16 0:45 

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.