Click here to Skip to main content
15,921,959 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to get the MaxValue using LINQ ?! Pin
Richard Deeming1-May-19 8:20
mveRichard Deeming1-May-19 8:20 
QuestionRe: How to get the MaxValue using LINQ ?! Pin
Maciej Los2-May-19 8:24
mveMaciej Los2-May-19 8:24 
AnswerRe: How to get the MaxValue using LINQ ?! Pin
Richard Deeming3-May-19 0:43
mveRichard Deeming3-May-19 0:43 
PraiseRe: How to get the MaxValue using LINQ ?! Pin
Maciej Los3-May-19 1:25
mveMaciej Los3-May-19 1:25 
AnswerRe: How to get the MaxValue using LINQ ?! Pin
Maciej Los3-May-19 1:34
mveMaciej Los3-May-19 1:34 
GeneralRe: How to get the MaxValue using LINQ ?! Pin
Abdalla Ben Omran3-May-19 2:30
Abdalla Ben Omran3-May-19 2:30 
Questiondata structure Pin
Member 1434080028-Apr-19 3:35
Member 1434080028-Apr-19 3:35 
AnswerRe: data structure Pin
OriginalGriff28-Apr-19 4:27
mveOriginalGriff28-Apr-19 4:27 
AnswerRe: data structure Pin
Luc Pattyn28-Apr-19 9:59
sitebuilderLuc Pattyn28-Apr-19 9:59 
QuestionHow to find the Max or the Highest value in (List) using just C# code and No LINQ Pin
Abdalla Ben Omran26-Apr-19 5:38
Abdalla Ben Omran26-Apr-19 5:38 
AnswerRe: How to find the Max or the Highest value in (List) using just C# code and No LINQ Pin
#realJSOP26-Apr-19 5:45
professional#realJSOP26-Apr-19 5:45 
GeneralRe: How to find the Max or the Highest value in (List) using just C# code and No LINQ Pin
Abdalla Ben Omran26-Apr-19 23:49
Abdalla Ben Omran26-Apr-19 23:49 
GeneralRe: How to find the Max or the Highest value in (List) using just C# code and No LINQ Pin
#realJSOP27-Apr-19 0:01
professional#realJSOP27-Apr-19 0:01 
GeneralRe: How to find the Max or the Highest value in (List) using just C# code and No LINQ Pin
Abdalla Ben Omran27-Apr-19 0:45
Abdalla Ben Omran27-Apr-19 0:45 
GeneralRe: How to find the Max or the Highest value in (List) using just C# code and No LINQ Pin
Gerry Schmitz27-Apr-19 2:50
mveGerry Schmitz27-Apr-19 2:50 
GeneralRe: How to find the Max or the Highest value in (List) using just C# code and No LINQ Pin
Abdalla Ben Omran27-Apr-19 6:32
Abdalla Ben Omran27-Apr-19 6:32 
GeneralRe: How to find the Max or the Highest value in (List) using just C# code and No LINQ Pin
Richard Deeming1-May-19 8:13
mveRichard Deeming1-May-19 8:13 
AnswerRe: How to find the Max or the Highest value in (List) using just C# code and No LINQ Pin
Richard Deeming26-Apr-19 5:55
mveRichard Deeming26-Apr-19 5:55 
QuestionHow to get an Not Empty Instance back ? Pin
Abdalla Ben Omran26-Apr-19 2:42
Abdalla Ben Omran26-Apr-19 2:42 
AnswerRe: How to get an Not Empty Instance back ? Pin
Richard Deeming26-Apr-19 3:14
mveRichard Deeming26-Apr-19 3:14 
QuestionWhat is Out in C# ? Pin
Abdalla Ben Omran25-Apr-19 23:13
Abdalla Ben Omran25-Apr-19 23:13 
AnswerRe: What is Out in C# ? Pin
OriginalGriff25-Apr-19 23:37
mveOriginalGriff25-Apr-19 23:37 
out is a keyword which says that a method parameter will be changed in the method, but that it is not given an initial value - so any value in the "outside world" will not be passed into the method, but the outside world variable will have the new value after the method returns.

When you pass a "normal" parameter, it is passed by value: a copy of the value in the variable is given to the method, and changes will not be reflected in the outside world:
C#
private void DoIt(int x)
   {
   x = x * 2;
   Console.WriteLine(x);
   }
...
   int x = 100;
   Console.WriteLine(x);
   DoIt(x);
   Console.WriteLine(x);
Will print
100
200
100
You can pass a value by reference, and the actual outside world value is used in the method:
C#
private void DoIt(ref int x)
   {
   x = x * 2;
   Console.WriteLine(x);
   }
...
   int x = 100;
   Console.WriteLine(x);
   DoIt(ref x);
   Console.WriteLine(x);
Will print
100
200
200
Or, you could give it as an out parameter:
C#
private void DoIt(out int x)
   {
   x = x * 2;
   Console.WriteLine(x);
   }
...
   int x = 100;
   Console.WriteLine(out x);
   DoIt(out x);
   Console.WriteLine(x);
And you will get compiler errors because x has no initial value inside the DoIt method.
So you change your code:
C#
private void DoIt(out int x)
   {
   x = 200;
   Console.WriteLine(x);
   }
...
   int x = 100;
   Console.WriteLine(x);
   DoIt(out x);
   Console.WriteLine(x);
Will print
100
200
200

It's not used that much, but it's a way to "return multiple values" from a method if you need to.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!

GeneralRe: What is Out in C# ? Pin
Abdalla Ben Omran25-Apr-19 23:50
Abdalla Ben Omran25-Apr-19 23:50 
GeneralRe: What is Out in C# ? Pin
OriginalGriff26-Apr-19 0:03
mveOriginalGriff26-Apr-19 0:03 
QuestionI want to generate/make my predefined variable name in the C# code Pin
Member 1330748425-Apr-19 5:19
Member 1330748425-Apr-19 5:19 

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.