Click here to Skip to main content
15,909,051 members
Home / Discussions / C#
   

C#

 
GeneralRe: implicit operators Pin
Colin Angus Mackay28-May-04 11:20
Colin Angus Mackay28-May-04 11:20 
wickerman.26 wrote:
I've got the binary operators to evaluate my object as a DateTime value working just fine. My assignment operators are another story entirely - how do I create an assignment operator without having the other data in my object get reset to their default values (as happens below)?

You can't. It is like if you cast between an int and a byte. A byte can hold values 0 to 255, an int can hold values -2billion to +2billion (approx.)

byte myByte = 100;<br />
int myInt = (int)myByte;<br />
// myInt is now 100


But if you do this:

int myInt = 1000;<br />
byte myByte = (byte)myInt;<br />
// ???? myByte is too small for the value in myInt


Actually the result is 232, which is the same as (myInt%256). This is because to fit into an int the data had to be truncated, and if we try and reassign the byte back to the int, we will only ever see as much as was truncated.






"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar

The Second EuroCPian Event will be in Brussels on the 4th of September

Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!


GeneralRe: implicit operators Pin
wickerman.261-Jun-04 6:16
wickerman.261-Jun-04 6:16 
GeneralC# Best Practice for Seperating Windows Form Pin
neffc28-May-04 8:52
neffc28-May-04 8:52 
GeneralRe: C# Best Practice for Seperating Windows Form Pin
leppie28-May-04 11:04
leppie28-May-04 11:04 
GeneralRe: C# Best Practice for Seperating Windows Form Pin
Colin Angus Mackay28-May-04 11:10
Colin Angus Mackay28-May-04 11:10 
QuestionReading a txt file to set properties ? Pin
Anonymous28-May-04 8:18
Anonymous28-May-04 8:18 
AnswerRe: Reading a txt file to set properties ? Pin
leppie28-May-04 11:12
leppie28-May-04 11:12 
AnswerRe: Reading a txt file to set properties ? Pin
MilesAhead29-May-04 5:26
MilesAhead29-May-04 5:26 
AnswerRe: Reading a txt file to set properties ? Pin
triso1-Jun-04 9:39
triso1-Jun-04 9:39 
AnswerRe: Reading a txt file to set properties ? Pin
triso1-Jun-04 9:41
triso1-Jun-04 9:41 
QuestionGhostscript: wrapper for C# ? Pin
TigerNinja_28-May-04 7:01
TigerNinja_28-May-04 7:01 
AnswerRe: Ghostscript: wrapper for C# ? Pin
Dave Kreskowiak28-May-04 7:52
mveDave Kreskowiak28-May-04 7:52 
QuestionHow to Pull an Image from a dll? Pin
BillyDvd28-May-04 6:01
BillyDvd28-May-04 6:01 
AnswerRe: How to Pull an Image from a dll? Pin
Dave Kreskowiak28-May-04 6:25
mveDave Kreskowiak28-May-04 6:25 
GeneralRemoting error propogation and FileNotFound Pin
SimonS28-May-04 4:33
SimonS28-May-04 4:33 
GeneralNumeric TextBox Pin
BaShOr28-May-04 4:26
BaShOr28-May-04 4:26 
GeneralRe: Numeric TextBox Pin
Dave Kreskowiak28-May-04 4:39
mveDave Kreskowiak28-May-04 4:39 
Generalremote object Pin
Silly Boy28-May-04 4:15
Silly Boy28-May-04 4:15 
GeneralRe: remote object Pin
Dave Kreskowiak28-May-04 4:29
mveDave Kreskowiak28-May-04 4:29 
GeneralPassing 'Int32' array to COM Pin
kskris28-May-04 2:35
kskris28-May-04 2:35 
GeneralTyped Collection Utility Pin
Colin Angus Mackay28-May-04 2:30
Colin Angus Mackay28-May-04 2:30 
GeneralRe: Typed Collection Utility Pin
Colin Angus Mackay28-May-04 2:48
Colin Angus Mackay28-May-04 2:48 
Generalnice of you Pin
Hesham Amin28-May-04 4:05
Hesham Amin28-May-04 4:05 
GeneralRe: nice of you Pin
Colin Angus Mackay28-May-04 5:00
Colin Angus Mackay28-May-04 5:00 
Generaldeploying application Pin
Ammar Ben Hadj Amor27-May-04 23:25
professionalAmmar Ben Hadj Amor27-May-04 23:25 

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.