Click here to Skip to main content
15,914,795 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Programming Lesson of the Day Pin
Jeremy Falcon25-Jan-17 10:17
professionalJeremy Falcon25-Jan-17 10:17 
GeneralRe: Programming Lesson of the Day Pin
irneb25-Jan-17 20:06
irneb25-Jan-17 20:06 
GeneralRe: Programming Lesson of the Day Pin
OriginalGriff25-Jan-17 22:07
mveOriginalGriff25-Jan-17 22:07 
GeneralRe: Programming Lesson of the Day Pin
den2k8825-Jan-17 22:22
professionalden2k8825-Jan-17 22:22 
GeneralRe: Programming Lesson of the Day Pin
Herbie Mountjoy26-Jan-17 0:41
professionalHerbie Mountjoy26-Jan-17 0:41 
GeneralRe: Programming Lesson of the Day Pin
englebart26-Jan-17 2:43
professionalenglebart26-Jan-17 2:43 
GeneralRe: Programming Lesson of the Day Pin
den2k8826-Jan-17 21:19
professionalden2k8826-Jan-17 21:19 
GeneralRe: Programming Lesson of the Day Pin
irneb26-Jan-17 1:43
irneb26-Jan-17 1:43 
Don't get me wrong ... I'm not dissing on C and saying C# is all that great. I was simply pointing out why the if statement would fail to even compile in this particular case when trying this in C#.

You make a point where C#'s strong typing does make a programmer's life more cumbersome - you'd need to convert a byte array into specific types to do what you want, though there is readily available built-in libraries for that, or you could use an unsafe code block and use pointers to cast one into the other (just like you'd have done in C). Point is it would make for more coding to achieve the same thing.

Though it's only in special circumstances (like your example) where this is beneficial. Nearly everywhere else it means there's less to think about (and guard against) due to the compiler checking types for you. If you find you constantly run into situations where you need to cast between types - then perhaps C# isn't the correct tool for the job and you'd be better off with C instead.

GeneralRe: Programming Lesson of the Day Pin
den2k8826-Jan-17 21:14
professionalden2k8826-Jan-17 21:14 
GeneralRe: Programming Lesson of the Day Pin
Alister Morton26-Jan-17 3:52
Alister Morton26-Jan-17 3:52 
GeneralRe: Programming Lesson of the Day Pin
Jeremy Falcon26-Jan-17 5:39
professionalJeremy Falcon26-Jan-17 5:39 
GeneralRe: Programming Lesson of the Day Pin
James Curran26-Jan-17 4:07
James Curran26-Jan-17 4:07 
GeneralRe: Programming Lesson of the Day Pin
Nelek25-Jan-17 11:07
protectorNelek25-Jan-17 11:07 
GeneralRe: Programming Lesson of the Day Pin
den2k8825-Jan-17 22:15
professionalden2k8825-Jan-17 22:15 
GeneralRe: Programming Lesson of the Day Pin
Gerry Schmitz26-Jan-17 6:51
mveGerry Schmitz26-Jan-17 6:51 
GeneralRe: Programming Lesson of the Day Pin
den2k8826-Jan-17 21:15
professionalden2k8826-Jan-17 21:15 
GeneralRe: Programming Lesson of the Day Pin
kdmote26-Jan-17 3:41
kdmote26-Jan-17 3:41 
GeneralRe: Programming Lesson of the Day Pin
James Curran26-Jan-17 4:05
James Curran26-Jan-17 4:05 
GeneralRe: Programming Lesson of the Day Pin
kdmote26-Jan-17 6:51
kdmote26-Jan-17 6:51 
GeneralRe: Programming Lesson of the Day Pin
Richard Deeming26-Jan-17 4:27
mveRichard Deeming26-Jan-17 4:27 
GeneralRe: Programming Lesson of the Day Pin
James Curran26-Jan-17 10:04
James Curran26-Jan-17 10:04 
PraiseRe: Programming Lesson of the Day Pin
Slow Eddie26-Jan-17 3:52
professionalSlow Eddie26-Jan-17 3:52 
GeneralRe: Programming Lesson of the Day Pin
den2k8825-Jan-17 6:23
professionalden2k8825-Jan-17 6:23 
GeneralRe: Programming Lesson of the Day Pin
KarstenK25-Jan-17 7:14
mveKarstenK25-Jan-17 7:14 
GeneralRe: Programming Lesson of the Day Pin
den2k8825-Jan-17 22:13
professionalden2k8825-Jan-17 22:13 

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.