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

C#

 
AnswerRe: Play/Pause/Stop media through ASIO driver using C# Pin
Brisingr Aerowing17-Oct-14 10:08
professionalBrisingr Aerowing17-Oct-14 10:08 
GeneralRe: Play/Pause/Stop media through ASIO driver using C# Pin
Praveen Raghuvanshi26-Oct-14 7:37
professionalPraveen Raghuvanshi26-Oct-14 7:37 
Questionanother Func-enstein weirdness : and yet another bad example of MS documentation PinPopular
BillWoodruff16-Oct-14 11:38
professionalBillWoodruff16-Oct-14 11:38 
AnswerRe: another Func-enstein weirdness : and yet another bad example of MS documentation Pin
Gerry Schmitz16-Oct-14 17:43
mveGerry Schmitz16-Oct-14 17:43 
AnswerRe: another Func-enstein weirdness : and yet another bad example of MS documentation Pin
OriginalGriff16-Oct-14 19:27
mveOriginalGriff16-Oct-14 19:27 
AnswerRe: another Func-enstein weirdness : and yet another bad example of MS documentation Pin
Richard Deeming17-Oct-14 5:28
mveRichard Deeming17-Oct-14 5:28 
Questionnecessity to cast return value to nullable in lambda expression ? Pin
BillWoodruff16-Oct-14 7:25
professionalBillWoodruff16-Oct-14 7:25 
AnswerRe: necessity to cast return value to nullable in lambda expression ? Pin
Richard Deeming16-Oct-14 8:12
mveRichard Deeming16-Oct-14 8:12 
The specification states:
Quote:

The second and third operands of the ?: operator control the type of the conditional expression.

Let X and Y be the types of the second and third operands. Then,
  • If X and Y are the same type, then this is the type of the conditional expression.
  • Otherwise, if an implicit conversion exists from X to Y, but not from Y to X, then Y is the type of the conditional expression.
  • Otherwise, if an implicit conversion exists from Y to X, but not from X to Y, then X is the type of the conditional expression.
  • Otherwise, no expression type can be determined, and a compile-time error occurs.



In the case of condition ? null : integer, the types of X and Y are null and Int32.
  • X and Y are not the same type.
  • There is no implicit conversion from null to Int32;
  • There is no implicit conversion from Int32 to null;
  • Therefore, a compile-time error occurs.


When you cast one of the operands to Nullable<Int32>, the result is:
  • X and Y are not the same type.
  • There is an implicit conversion from null to Nullable<Int32>; -or-
  • There is an implicit conversion from Int32 to Nullable<Int32>;
  • Therefore, the type of the expression is Nullable<Int32>.


There are several options for the expression which will work:
  • (i2 == 0) ? (int?) null : i1 / i2
  • (i2 == 0) ? default(int?) : i1/i2
  • (i2 == 0) ? null : (int?)i1 / i2
  • (i2 == 0) ? null : i1 / (int?)i2




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: necessity to cast return value to nullable in lambda expression ? Pin
BillWoodruff16-Oct-14 8:44
professionalBillWoodruff16-Oct-14 8:44 
GeneralRe: necessity to cast return value to nullable in lambda expression ? Pin
Richard Deeming16-Oct-14 8:49
mveRichard Deeming16-Oct-14 8:49 
AnswerRe: necessity to cast return value to nullable in lambda expression ? Pin
Pete O'Hanlon16-Oct-14 8:13
mvePete O'Hanlon16-Oct-14 8:13 
GeneralRe: necessity to cast return value to nullable in lambda expression ? Pin
BillWoodruff16-Oct-14 8:44
professionalBillWoodruff16-Oct-14 8:44 
QuestionHow to read tables in Excel Worksheet witc C# and XML Pin
Member 1110881716-Oct-14 3:13
Member 1110881716-Oct-14 3:13 
AnswerRe: How to read tables in Excel Worksheet witc C# and XML Pin
BillWoodruff16-Oct-14 5:25
professionalBillWoodruff16-Oct-14 5:25 
GeneralRe: How to read tables in Excel Worksheet witc C# and XML Pin
Member 1110881716-Oct-14 21:14
Member 1110881716-Oct-14 21:14 
AnswerRe: How to read tables in Excel Worksheet witc C# and XML Pin
Eddy Vluggen16-Oct-14 9:05
professionalEddy Vluggen16-Oct-14 9:05 
QuestionC#/C wrapper Pin
Nikolaj jensen16-Oct-14 2:39
Nikolaj jensen16-Oct-14 2:39 
AnswerRe: C#/C wrapper Pin
Richard MacCutchan16-Oct-14 2:59
mveRichard MacCutchan16-Oct-14 2:59 
GeneralRe: C#/C wrapper Pin
Nikolaj jensen16-Oct-14 3:52
Nikolaj jensen16-Oct-14 3:52 
GeneralRe: C#/C wrapper Pin
Richard MacCutchan16-Oct-14 3:56
mveRichard MacCutchan16-Oct-14 3:56 
GeneralRe: C#/C wrapper Pin
Nikolaj jensen16-Oct-14 21:43
Nikolaj jensen16-Oct-14 21:43 
QuestionHow to convert HTML Form data into RTF File Pin
mukulsharma114616-Oct-14 1:37
mukulsharma114616-Oct-14 1:37 
AnswerRe: How to convert HTML Form data into RTF File Pin
Richard MacCutchan16-Oct-14 2:55
mveRichard MacCutchan16-Oct-14 2:55 
AnswerRe: How to convert HTML Form data into RTF File Pin
Eddy Vluggen16-Oct-14 9:07
professionalEddy Vluggen16-Oct-14 9:07 
GeneralRe: How to convert HTML Form data into RTF File Pin
mukulsharma114616-Oct-14 19:56
mukulsharma114616-Oct-14 19:56 

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.