|
Thanks Christian,
Is there a built-in data structure like MuitlMap in C++, which allows one key maps to multiple values in C#?
regards,
George
|
|
|
|
|
|
Thanks Christian,
If not using database, any ideas about what is the best solution you could have with memory based data structures?
regards,
George
|
|
|
|
|
Can anybody give me the sample code for this.
program that takes as its first argument one of the words 'sum,' 'product,' 'mean,' or 'sqrt' and for further arguments a series of numbers. The program applies the appropriate function to the series.
Requires basic control flow, basic operators, and the math library. (Complex numbers available?)
What are arrays like?
What about parsing / implicit conversion?
Are functions first-class (availability of Map() and Apply())?
Error handling: What happens on invalid data?
Free sample codes are here http://allabout-dotnet.blogspot.com
|
|
|
|
|
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.
|
|
|
|