Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I'am Beginner In C# I want to have your help
Thank for every one who help Me.
Posted
Comments
Rajeev Jayaram 19-Feb-12 12:58pm    
Are you a beginner to C# or New to programming itself?
Sergey Alexandrovich Kryukov 22-May-12 1:58am    
I see no use in answering such questions.
--SA

C#
let max = 0;
foreach (number n in numbers)
{
    if n is greater than max then
        let max = n
}
 
Share this answer
 
C#
max = Math.Max(Math.Max(n1, n2), n3));
 
Share this answer
 
It might help you,

C#
using System;
using System.Linq;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arrayToCheck = { 100, 2, 3 };
            Console.WriteLine(arrayToCheck.ToArray().Max());
        }
    }
}

:)
 
Share this answer
 
For Array

C#
int[] arr = new int[10] { 45, 3, 64, 6, 24, 75, 3, 6, 24, 45 };
int firstHighestNumber = arr[0];

for(int i = 0; i<arr.Length; i++)
{
    if (arr[i]>firstHighestNumber)
    {
        firstHighestNumber = arr[i];
    }
}


If you have a, b, c
C#
int a = 1;
int b = 2;
int c = 3;

int d =  a > b ? a : b;
return c > d ? c : d;


Else Simple C Language Funda...
Suppose you have three number X, Y, Z
Then
C#
int X, Y, Z;
int maxVal = X;

if(Y > X)
maxVal = Y;

if(Z > X)
maxVal = Z;

return maxVal;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900