is this type of thing ok.
namespace myclass
{
class set
{
List
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted May 4, 2011, 3:43 PM
Both of these have UnionWith, IntersectWith, ExceptWith and SymmetricExceptWith methods built in, silently ignore attempts to add duplicates and are lightning fast in operation.
Andrew FensterPosted May 4, 2011, 3:15 PM
VulpesPosted May 4, 2011, 2:13 PM
John,
No problem :)
John MieskePosted May 4, 2011, 2:06 PM
List
VulpesPosted May 4, 2011, 2:06 PM
If you don't override it, the ToString() method which all classes inherit from System.Object displays the fully qualified name of the class i.e. myclass.set in this example. Console.WriteLine() automatically applies the ToString() method to its argument if you don't call it explicitly.
Sam HobbsPosted May 4, 2011, 2:03 PM
namespace _121172
{
class set
{
public set(string comment)
{
Console.WriteLine(comment);
}
public set union()
{
set tempSet = new set("union");
return tempSet;
}
}
class Program
{
static void Main(string[] args)
{
set set1 = new set("initial");
set set2 = set1.union();
}
}
}
John MieskePosted May 4, 2011, 1:55 PM
using System;
using System.Collections.Generic;
namespace myclass
{
class set
{
List<object> mList;
//constructors and stuff
public set union(set passedSet)
{
set tempSet = new set();
//do stuff
Console.WriteLine("Creating a union ...");
return tempSet;
}
}
class Test
{
static void Main()
{
set s1 = new set();
Console.WriteLine(s1);
set s2 = new set();
Console.WriteLine(s2);
set s3 = s1.union(s2);
Console.WriteLine(s3);
Console.ReadKey();
}
}
}
OUTPUT :
myclass.set
myclass.set
Creating a union ...
myclass.set
mList shows not being used.. but other then that it works.
VulpesPosted May 4, 2011, 1:44 PM
Any error you're getting must therefore be caused by something else. Notice, in particular, that the set class should be declared to be public if you want to access it from a client of the dll.
John MieskePosted May 4, 2011, 1:09 PM
From what I am seeing your calling this :
set tempSet = new set();
INSIDE of the class that its supposed to be for.
Your class :
class set
{
public set union(set passedSet)
{
//do stuff
return tempSet;
}
}
you cannot set it up like that. Now if your calling from another class :
class Program
{
set tempSet = new set();
test = tempSet.union();
}
then it should work just fine. Keep in mind, you have to setup what union is going to return. in other words, how you are defining 'test' in this above example.