|
|
Hi all,
i am new to programming in C#. i dont know to code it to get the output ie., the largest among the four numbers and the user will give the input as numbers. and the munbers are int type inta,b,c,d;
i need the code for largest among the four numbers of int a,b,c,d.
pleae help me in sending code.
regards,
chitra.
|
|
|
|
|
you can apply a simple algorithm,
if (a > b)
{
if (a > C)
{
if (a > d)
{
return a;
}
else
{
return d;
}
}
else
{
if (c > d)
{
return c;
}
else
{
return d;
}
}
}
else
{
if (b > C)
{
if (b > d)
{
return b;
}
else
{
return d;
}
}
else
{
if (c > d)
{
return c;
}
else
{
return d;
}
}
}
Learning is a never ending process of Life.
|
|
|
|
|
There's a simpler algorithm:
int Max4(int a, int b, int c, int d)
{
return Math.Max(Math.Max(a, b), Math.Max(c, d));
} Is this for a school assignment?
|
|
|
|
|
Luis Alonso Ramos wrote: Is this for a school assignment?
Seems pretty likely - and you just did him no favours by doing it for him.
|
|
|
|
|
Yeah, I didn't notice until I saw other posts from this same guy...
Anyway, the solution was trivial if he knew of the existence of Math.Max .
|
|
|
|
|
i'd use:
int[] numbers = {a,b,c,d};
int MaxNumber = GetHighestNumber(numbers);
public int GetHighestNumber(int[] testNumbers)
{
int max = 0;
foreach(int i in testNumbers)
{
//algorithm goes here
}
return max;
}
|
|
|
|
|
Using extension methods (C# 3.0):
int[] nums = {a,b,c,d};
int max = nums.GetLargest();
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
I have a solution that has two c# project named test and test.test, but MSBuild doesn't compile test.test.csproj.
I am trying to compile like this
msbuild.exe "c:\test.sln" "/t:test" "/p:Configuration=Debug": This command compiles correctly test project in test.sln solution.
msbuild.exe "c:\test.sln" "/t:test.test" "/p:Configuration=Debug":But this command doesn't compile test.test project, and gives the error that unable to find project test.test in test solution.
Any help regarding that.
Warm Regards,
Mushq
|
|
|
|
|
hi,
It should read smth like /t:Rebuild or /t:Compile or /t:Rebuild;Compile.
Greetings
Kaine
|
|
|
|
|
you are right but we can also provide target for individual project in a solution file, for example i can also do this
msbuild.exe "c:\test.sln" "/t:Rebuild:test" "/p:Configuration=Debug":
Look at the target, now the above command is going to rebuild only test project in test solution file.
Regards,
Mushq
|
|
|
|
|
Didnt know that last part... Thanks for the update
Greetings,
Kaine
|
|
|
|
|
hi, can anybody tell me is it possible to put multiple controls in a single grid cell? for eg, a static text box and a button inside one cell. use DataGridView class in C#
thanks!
Nathan
|
|
|
|
|
nathan7 wrote:
can anybody tell me is it possible to put multiple controls in a single grid cell?
Yes. You can use TemplateField
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
See here[^]
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
I have to insert images in Access db using C#.net. what datatype should i use to achieve that?
Thanks in advance
|
|
|
|
|
Hi,
Use the datatype as "OLE Object" for storing images in MSACCESS. I think that should work out
Also google on the same, you will get many articles for the same
Thanking you in Advance
Kind Regards
Pratik Shah
|
|
|
|
|
Hi all,
i need to set the precision to thrre digits of a double datatype
eg.
see i have a value 22.222623
i need to change the above 22.222623 to 22.223 how?
thnx in advance
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
Do u want it in C#?? or is that a DB question
Thanking you in Advance
Regards
Pratik Shah
|
|
|
|
|
i want it in c# for my windows application
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
Try using Math.Round function.
|
|
|
|
|
Hi all,
I am new in C#. and i have been asked to develop a class in which the task is as follows
Electricity bill with in range and also the due date i have to check it out and then only i have to get the amount.
for example if the reading is from 0 to 100 units we have to charge Rs.150, 100 to 200 units amount is Rs.250,200 to 300 units amount is Rs.350 and more than 300 units means amount as 500Rs. and also we have to check the date if it is paid within the date ther is no fine if the is late payment means we have to charge them with 50 rs as fine.
Pls help me guyz itz very urgent .
if anybody has code please send it.
With Regards,
Sakthi
|
|
|
|
|
Sakthi Sat wrote: if anybody has code please send it.
We are not here to do your homework for you, if you want help with a specific problem then ask.
|
|
|
|
|
Hello,
I am writing a code in C#.net which would fire powershell commands. The sample code which I have got from internet uses System.Management.Automation and other such namespaces. Upon browsing some sites I found that I have to reference System.Management.Automation.dll which can be found in GAC however I could not see the same in references dialog from Visual Studio. I removed the dll from GAC using powershell command and placed it to a local directory but still referencing the dll from Visual Studio gives error saying that its not a valid assembly or a COM dll. Please help me and give me some directions on what could be the problem. Below is the environment I am using
Windows Powershell 1.0 (for XP SP2)
Windows XP SP2
.NET Framework 2.0
Visual Studio 2003
Thanks
Abhishek.
Learning is a never ending process of Life.
|
|
|
|
|
abhinarulkar wrote: .NET Framework 2.0
Visual Studio 2003
You cannot create programs for .NET 2.0 using VS2003. You might want to look at the Express editions if you want a free alternative for .NET 2.
|
|
|
|