Click here to Skip to main content
15,919,774 members
Home / Discussions / C#
   

C#

 
AnswerRe: 8086 assembler Pin
Luc Pattyn23-Oct-11 9:42
sitebuilderLuc Pattyn23-Oct-11 9:42 
GeneralRe: 8086 assembler Pin
Paul Conrad23-Oct-11 9:55
professionalPaul Conrad23-Oct-11 9:55 
Questionconvert unicode to iransystem Pin
mersad0022-Oct-11 6:33
mersad0022-Oct-11 6:33 
AnswerRe: convert unicode to iransystem Pin
BobJanova23-Oct-11 22:29
BobJanova23-Oct-11 22:29 
AnswerRe: convert unicode to iransystem Pin
Pascal Ganaye23-Oct-11 23:05
Pascal Ganaye23-Oct-11 23:05 
AnswerRe: convert unicode to iransystem Pin
Keith Barrow24-Oct-11 1:53
professionalKeith Barrow24-Oct-11 1:53 
QuestionAnimation format Pin
Aleonis22-Oct-11 5:59
Aleonis22-Oct-11 5:59 
QuestionDoes anyone know how to unbox or convert a "1" as a nullable long? Pin
Alaric_22-Oct-11 5:37
professionalAlaric_22-Oct-11 5:37 
...That pretty much says it all:
C#
private void SetValue(object instance, PropertyInfo property, object data)
{
   //some preliminary checks
     if(property.PropertyType.IsAssignableFrom(data.GetType()))
        property.SetValue(instance, data, null);
     else
     {
         if(data is int)
         {
             int? unboxed = (int?)data;
             property.SetValue(instance, unboxed, null);
         }
         else
             property.SetValue(instance, Convert.ChangeType(data.ToString(), property.PropertyType), null);
}


I have an object that has a property of type long? and the value "1" cannot be pushed into it.

The failure is inside the "if(data is int)" branch.
"Object of type 'System.Int32' cannot be converted to type 'System.Nullable '1[System.Int64]'


How do I go about getting a System.Int32 into a System.Nullable [System.Int64] ??
"I need build Skynet. Plz send code"

AnswerRe: Does anyone know how to unbox or convert a "1" as a nullable long? Pin
Alaric_22-Oct-11 6:03
professionalAlaric_22-Oct-11 6:03 
GeneralRe: Does anyone know how to unbox or convert a "1" as a nullable long? Pin
Alaric_22-Oct-11 6:04
professionalAlaric_22-Oct-11 6:04 
QuestionScope issue declaring a delegate within a static class Pin
dotman121-Oct-11 23:15
dotman121-Oct-11 23:15 
AnswerRe: Scope issue declaring a delegate within a static class Pin
dotman121-Oct-11 23:33
dotman121-Oct-11 23:33 
QuestionAsync Socket Receive Pin
Richard Andrew x6421-Oct-11 6:48
professionalRichard Andrew x6421-Oct-11 6:48 
AnswerRe: Async Socket Receive Pin
Eddy Vluggen21-Oct-11 9:04
professionalEddy Vluggen21-Oct-11 9:04 
AnswerRe: Async Socket Receive Pin
TheGreatAndPowerfulOz21-Oct-11 9:20
TheGreatAndPowerfulOz21-Oct-11 9:20 
AnswerRe: Async Socket Receive Pin
jschell21-Oct-11 10:59
jschell21-Oct-11 10:59 
GeneralRe: Async Socket Receive Pin
Richard Andrew x6421-Oct-11 11:14
professionalRichard Andrew x6421-Oct-11 11:14 
GeneralRe: Async Socket Receive Pin
jschell21-Oct-11 12:15
jschell21-Oct-11 12:15 
GeneralRe: Async Socket Receive Pin
Richard Andrew x6421-Oct-11 17:55
professionalRichard Andrew x6421-Oct-11 17:55 
QuestionMIME Attachment Names containing Extended Characters Fails Pin
Chadwick Posey21-Oct-11 4:39
Chadwick Posey21-Oct-11 4:39 
AnswerRe: MIME Attachment Names containing Extended Characters Fails Pin
Eddy Vluggen21-Oct-11 9:13
professionalEddy Vluggen21-Oct-11 9:13 
GeneralRe: MIME Attachment Names containing Extended Characters Fails Pin
Chadwick Posey21-Oct-11 10:17
Chadwick Posey21-Oct-11 10:17 
GeneralRe: MIME Attachment Names containing Extended Characters Fails Pin
Chadwick Posey24-Oct-11 6:28
Chadwick Posey24-Oct-11 6:28 
QuestionSome data gets lost between WCF server and client Pin
teknolog12321-Oct-11 2:06
teknolog12321-Oct-11 2:06 
AnswerRe: Some data gets lost between WCF server and client Pin
OriginalGriff21-Oct-11 2:31
mveOriginalGriff21-Oct-11 2:31 

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.