|
How about doing your own homework.
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
smileguy wrote: program that takes as its first argument one of the words 'sum,' 'product,' 'mean,' or 'sqrt' and for further arguments a series of numbers
Do you mean takes as command line parameters. Or takes as input via the console. Or takes as input via a windows form. Or takes as input via....
smileguy wrote: Requires basic control flow, basic operators, and the math library.
Naturally, what else would it have?
smileguy wrote: What are arrays like?
They are like sequential list of things.
smileguy wrote: What about parsing / implicit conversion?
I don't know what you mean by that.
smileguy wrote: Are functions first-class (availability of Map() and Apply())?
Functions? You might want to go to VB.NET for that. We have methods in C#.
smileguy wrote: Error handling: What happens on invalid data?
You tell me, it is your program.
|
|
|
|
|
|
Is some course just starting, or have you got this far before falling apart ?
You need to do your own homework, if we did it, how would that help you ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Sure:
namespace Homework
{
public static class Math
{
[System.STAThreadAttribute()]
public static int
Main
(
string[] args
)
{
if ( args.Length > 1 )
{
System.Console.WriteLine ( DoMath ( args ) ) ;
}
return ( 0 ) ;
}
}
}
Now just write the DoMath method.
|
|
|
|
|
Now that was a brilliant take on how to answer a homework question... consider it stolen for future use!
Peter the small turnip
(1) It Has To Work. --RFC 1925[^]
|
|
|
|
|
|
I was wondering something...
Is it possible do do something like:
string s1 = "12345";
string s2 = s1.RemoveNum("5");
MessageBox.Show(s2);
Where further down you add the RemoveNum() method ONTO the string type?
something like...
public static string add RemoveNum(string num)
{
return string.Replace(num, "");
}
?
Just wondering...
-= Reelix =-
|
|
|
|
|
Why dont you just test this instead of wondering??
|
|
|
|
|
public static string add RemoveNum(string num)
{
return string.Replace(num, "");
}
obviously doesnt work (Seeing as I made it up on the spot :p)
Was googling around, and couldn't find anything particularly useful...
You can't override, since it doesnt exist...
I'm just wondering if there's a way TO do it
-= Reelix =-
|
|
|
|
|
OOP way to augment functionality is inheritance, but no luck this time: String class is sealed.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Dang :/
No evil way to hack through it? :p
-= Reelix =-
|
|
|
|
|
Of course there are ways, evil,
but you have to ask the devil.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
*Decompiles the .NET Framework into Assembly*
*Inserts a new String Method*
*Recompiles*
*Looks Innocent*
*Thinks...*
Dang... Will only work on my PC
-= Reelix =-
|
|
|
|
|
check out extension methods
betonglasermur.FeedDwarf(pur_is, 17);
ProcessStartupInfo.AintNotCreateNoWindow = (false && !true) != (true || false) ? false == true ? true : false : (true != false && false);
Morgonen är tröttmans mecka
|
|
|
|
|
|
VICTORY!!!
using System;
class String
{
public string RemoveFirst(string num)
{
string toReturn = num.Remove(0, 1);
return toReturn;
}
}
class ExtMethodDemo
{
static void Main(string[] args)
{
String r1 = new String();
string r2 = r1.RemoveFirst("12345");
Console.WriteLine(r2);
Console.ReadLine();
}
}
Thanks laserbaronen!!!
-= Reelix =-
|
|
|
|
|
hmm o_o
public static class ExtMethods
{
public static string RemoveFirst(this string str)
{
return str.Remove(0,1);
}
}
class ExtMethodDemo
{
static void Main(string[] args)
{
string r1 = "12345".RemoveFirst();
Console.WriteLine(r1);
Console.ReadLine();
}
}
was thinking something like this
betonglasermur.FeedDwarf(pur_is, 17);
ProcessStartupInfo.AintNotCreateNoWindow = (false && !true) != (true || false) ? false == true ? true : false : (true != false && false);
Morgonen är tröttmans mecka
modified on Tuesday, May 20, 2008 10:05 AM
|
|
|
|
|
there is a way, using extension methods. but this requires c# 3.0 ..
Extension methods are static methods that can be invoked using instance method syntax. In effect, extension methods make it possible to extend existing types and constructed types with additional methods.
|
|
|
|
|
buchstaben wrote: In effect, extension methods make it possible
make it appear possible, when in fact it isn't.
|
|
|
|
|
PIEBALDconsult wrote: buchstaben wrote:
In effect, extension methods make it possible
make it appear possible, when in fact it isn't.
that's just what c# 3.0 specification says.
|
|
|
|
|
Hello everyone,
I understand there is no need to call Dispose explicitly when dealing with StreamReader/StreamWriter object instances since GC will take care of it in Finalizer method.
My question is, I want to know the benefits and potential issues of using "using" statement to deal with StreamReader/StreamWriter.
thanks in advance,
George
|
|
|
|
|
George_George wrote: I understand there is no need to call Dispose explicitly when dealing with StreamReader/StreamWriter object instances
you may not need to, but I would suggest its still good practice.
I always use using when dealing with stream readers/writers
using (StreamReader sr = new StreamReader(someStream))
{
...
}
|
|
|
|
|
Thanks J4amieC,
What is the benefit?
regards,
George
|
|
|
|