Click here to Skip to main content
15,916,693 members
Home / Discussions / C#
   

C#

 
QuestionCasting objects returned by reflection to a generic object Pin
Omer S.9-Dec-08 19:46
Omer S.9-Dec-08 19:46 
AnswerRe: Casting objects returned by reflection to a generic object Pin
leppie9-Dec-08 20:16
leppie9-Dec-08 20:16 
GeneralRe: Casting objects returned by reflection to a generic object Pin
Omer S.9-Dec-08 23:44
Omer S.9-Dec-08 23:44 
QuestionHow to add custom event log type in windows event log via C# [modified] Pin
Chintan.Desai9-Dec-08 19:45
Chintan.Desai9-Dec-08 19:45 
Questiondatagridview Pin
kulandaivel_mca20079-Dec-08 18:20
kulandaivel_mca20079-Dec-08 18:20 
AnswerRe: datagridview Pin
Christian Graus9-Dec-08 18:20
protectorChristian Graus9-Dec-08 18:20 
AnswerRe: datagridview Pin
Brij9-Dec-08 18:39
mentorBrij9-Dec-08 18:39 
QuestionI have problem with namespace and property, could someone show me what I need to do. Pin
Fabyta9-Dec-08 18:09
Fabyta9-Dec-08 18:09 
// Exception Handling

using System;
using Students;

public class ExceptionHandling {

static void Main(){

// We declare two students object references, but only instantiate one
// Student object; s2 is given a value of null, indicating that it
// isn't presently holding onto any object.

student s1 = new student();
student s2 = null;

// Exception handling is now in place.

try {
Console.WriteLine("Initializing students....");

// this line executes without throwing exception.

s1.Name = "Fred";

// This next line of code throws a NullReferenceException at run time because
// s2 was never initialized to refer to an actual Student object ...

s2.Name = "Mary";

// ... and as soon as the exception is detected by the runtime, execution
// jumps out of the try block -- none of the remaining code in
// this try block will be executed -- and into the first catch block
// below that is found to match a NullReferenceException, if any.

s1.Major = "MATH";
S2.Major = "SCIENCE";

Console.WriteLine("Initialization successfully completed.");
} // end of try block

//Pseudocode.

catch (UnrelatedExceptionType e1) {
// exception handing code fo this type of (hypothetical) exception
// goes here ... but, since our example doesn't involve throwing this
// particular type of exception at run time, this catch block will be
// skipped over without being executed.

Console.WriteLine("UnrelatedExceptionType was detected ...");
} // end of catch (UnrelatedExceptionType e1)

catch (NullReferenceException e2) {

// Here where we place the code for what the program should do if
// a null reference ws detected at run time.

Console.WriteLine("Whoops -- we forgot to initialize all of the students!");
} // end of catch (NullReference Exception e2)

finally {

// This code gets executed whether or not an exception occured; that is,
// whether we made it through the try block without any exceptions being
// thrown, or whether one of the catch blocks was triggered.

Console.WriteLine("Finally");
} // end of finally

// After the finally block executes, control transfers to the
// line of code immediately following block.

Console.WriteLine("Continuing along our merry way ...");
}
}


// This class has the simple name "Student".
using System;

namespace Students

{
public class student {

private string name;
private string major;

public string Name {
get{
return name;
}
set {
name = value;
}
}
public string Major {
get{
return name;
}
set {
major = value;
}
}

}
}
AnswerRe: I have problem with namespace and property, could someone show me what I need to do. Pin
Christian Graus9-Dec-08 18:23
protectorChristian Graus9-Dec-08 18:23 
GeneralRe: I have problem with namespace and property, could someone show me what I need to do. Pin
Fabyta9-Dec-08 18:35
Fabyta9-Dec-08 18:35 
GeneralRe: I have problem with namespace and property, could someone show me what I need to do. Pin
Christian Graus9-Dec-08 18:50
protectorChristian Graus9-Dec-08 18:50 
GeneralRe: I have problem with namespace and property, could someone show me what I need to do. Pin
Fabyta10-Dec-08 1:36
Fabyta10-Dec-08 1:36 
QuestionCommunicating thru Serial port and UART interface Pin
TJS4u9-Dec-08 18:06
TJS4u9-Dec-08 18:06 
AnswerRe: Communicating thru Serial port and UART interface Pin
N a v a n e e t h9-Dec-08 18:12
N a v a n e e t h9-Dec-08 18:12 
GeneralRe: Communicating thru Serial port and UART interface Pin
Luc Pattyn9-Dec-08 23:41
sitebuilderLuc Pattyn9-Dec-08 23:41 
QuestionSerialization problem Pin
Richard Blythe9-Dec-08 18:01
Richard Blythe9-Dec-08 18:01 
AnswerRe: Serialization problem Pin
N a v a n e e t h9-Dec-08 18:10
N a v a n e e t h9-Dec-08 18:10 
QuestionNot being able to close an application with Alt-F4 Pin
Joshomedia9-Dec-08 13:48
Joshomedia9-Dec-08 13:48 
AnswerRe: Not being able to close an application with Alt-F4 Pin
User 43300289-Dec-08 15:09
User 43300289-Dec-08 15:09 
AnswerRe: Not being able to close an application with Alt-F4 [modified] Pin
PIEBALDconsult9-Dec-08 16:52
mvePIEBALDconsult9-Dec-08 16:52 
AnswerRe: Not being able to close an application with Alt-F4 Pin
DaveyM6910-Dec-08 5:32
professionalDaveyM6910-Dec-08 5:32 
QuestionSendMessage Issues Pin
San249-Dec-08 10:43
San249-Dec-08 10:43 
AnswerRe: SendMessage Issues Pin
Christian Graus9-Dec-08 11:18
protectorChristian Graus9-Dec-08 11:18 
GeneralRe: SendMessage Issues Pin
San2410-Dec-08 3:30
San2410-Dec-08 3:30 
QuestionHow to configure TCPIP programatically Pin
s196675m9-Dec-08 10:03
s196675m9-Dec-08 10:03 

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.