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

C#

 
GeneralRe: What's the difference using a cast or C#'s 'as' Pin
Martin Hart Turner23-Nov-08 22:38
Martin Hart Turner23-Nov-08 22:38 
GeneralRe: What's the difference using a cast or C#'s 'as' Pin
James Simpson23-Nov-08 22:48
James Simpson23-Nov-08 22:48 
GeneralRe: What's the difference using a cast or C#'s 'as' Pin
Simon P Stevens23-Nov-08 22:59
Simon P Stevens23-Nov-08 22:59 
GeneralRe: What's the difference using a cast or C#'s 'as' Pin
James Simpson23-Nov-08 23:07
James Simpson23-Nov-08 23:07 
GeneralRe: What's the difference using a cast or C#'s 'as' Pin
Simon P Stevens23-Nov-08 23:12
Simon P Stevens23-Nov-08 23:12 
GeneralRe: What's the difference using a cast or C#'s 'as' Pin
Simon P Stevens23-Nov-08 22:57
Simon P Stevens23-Nov-08 22:57 
GeneralRe: What's the difference using a cast or C#'s 'as' Pin
Martin Hart Turner23-Nov-08 23:37
Martin Hart Turner23-Nov-08 23:37 
GeneralRe: What's the difference using a cast or C#'s 'as' Pin
Chris Maunder23-Nov-08 22:53
cofounderChris Maunder23-Nov-08 22:53 
I'm going to move this to the C# forum, but first an answer:

Do
MyObject thing = new MyObject();

// 1. 
MyOtherObject otherThing = thing as MyOtherObject;

// 2.
MyOtherObject otherThing = (MyOtherObject) thing;

1 will have otherThing == null. 2 will throw an exception. 1 allows you (in conjunction with is to write safe, polite code that handles bad casts intelligently. 2 just barfs on the carpet like a mangy cat.

cheers,
Chris Maunder
CodeProject.com : C++ MVP

QuestionReplaces "[fieldname]" in the HTML template document with data from the corresponding column of the SQLite table. Pin
Tsodgorhuu23-Nov-08 21:00
Tsodgorhuu23-Nov-08 21:00 
AnswerRe: Replaces "[fieldname]" in the HTML template document with data from the corresponding column of the SQLite table. Pin
Thomas Weller23-Nov-08 21:30
Thomas Weller23-Nov-08 21:30 
AnswerRe: Replaces "[fieldname]" in the HTML template document with data from the corresponding column of the SQLite table. Pin
Ashfield23-Nov-08 21:50
Ashfield23-Nov-08 21:50 
GeneralRe: Replaces "[fieldname]" in the HTML template document with data from the corresponding column of the SQLite table. Pin
Guffa23-Nov-08 23:09
Guffa23-Nov-08 23:09 
QuestionA program to delete first n bytes in a file Pin
Matjaz-xyz23-Nov-08 20:47
Matjaz-xyz23-Nov-08 20:47 
AnswerRe: A program to delete first n bytes in a file Pin
Christian Graus23-Nov-08 20:50
protectorChristian Graus23-Nov-08 20:50 
GeneralRe: A program to delete first n bytes in a file Pin
Matjaz-xyz23-Nov-08 21:00
Matjaz-xyz23-Nov-08 21:00 
GeneralRe: A program to delete first n bytes in a file Pin
Guffa23-Nov-08 21:38
Guffa23-Nov-08 21:38 
GeneralRe: A program to delete first n bytes in a file Pin
Matjaz-xyz23-Nov-08 21:53
Matjaz-xyz23-Nov-08 21:53 
GeneralRe: A program to delete first n bytes in a file Pin
Giorgi Dalakishvili23-Nov-08 22:00
mentorGiorgi Dalakishvili23-Nov-08 22:00 
GeneralRe: A program to delete first n bytes in a file Pin
Matjaz-xyz23-Nov-08 22:23
Matjaz-xyz23-Nov-08 22:23 
GeneralRe: A program to delete first n bytes in a file Pin
Giorgi Dalakishvili23-Nov-08 22:37
mentorGiorgi Dalakishvili23-Nov-08 22:37 
GeneralRe: A program to delete first n bytes in a file [modified] Pin
Matjaz-xyz23-Nov-08 23:42
Matjaz-xyz23-Nov-08 23:42 
GeneralRe: A program to delete first n bytes in a file Pin
Giorgi Dalakishvili24-Nov-08 0:30
mentorGiorgi Dalakishvili24-Nov-08 0:30 
GeneralRe: A program to delete first n bytes in a file Pin
Matjaz-xyz24-Nov-08 1:42
Matjaz-xyz24-Nov-08 1:42 
GeneralRe: A program to delete first n bytes in a file Pin
Giorgi Dalakishvili24-Nov-08 1:46
mentorGiorgi Dalakishvili24-Nov-08 1:46 
GeneralRe: A program to delete first n bytes in a file Pin
Matjaz-xyz24-Nov-08 2:16
Matjaz-xyz24-Nov-08 2:16 

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.