creating multiple instances of an enumerator

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,
i need help building multiple instances of an enumerator and naming each one
filter1, filter2, filterN depending on how many the user requires, here is
the code i have so far

public enum FilterType
{
None,
ADX
MOM
}


public class System()
{
private int noOfFilters = 0;

[Category("Filters")]
public int NoOfFilters
{
get { return noOfFilters;}
set { noOfFilters = value;}
}

public void makeFilters(int i)
{
i = noOfFilters;
for (int j, j < i-1, j++)
{
int k = j+1;
private FilterType */do not know to name the instance filter1,
filter2 etc*/ = FilterType.None;
}
 
i need help building multiple instances of an enumerator and naming each one
filter1, filter2, filterN depending on how many the user requires, here is
the code i have so far

I'm afraid we're going to need more information - it's not really
clear what you need to do, or what the problem is.

Also, are you using C# 2? If so, enumerators are much easier to
implement using iterator blocks.

Jon
 
basically just looking at the makefilters() method in each iteration i want
to be able to create a new instance of the enum "FilterType" and name it
filter1 for the first one and filter2 for the next and so on depending on the
value of noOfFilters which is user defined
i.e
public void makeFilters()
{

for ( int j=1; j < noOfFilters +1; j++ )
{
//create a new instance of the enumerator FilterType and name it
"filter plus the value of int j" eg filter2 or filter3 depending on where
we are in the iteration
}
also while on this subject is is possible to create a property for each
instance of FilterType that the method has created at the same time
 
basically just looking at the makefilters() method in each iteration i want
to be able to create a new instance of the enum "FilterType" and name it
filter1 for the first one and filter2 for the next and so on depending on the
value of noOfFilters which is user defined

Hang on - you need to be very clear whether you're talking about an
*enumerator* (as per the subject) or an *enumeration* (i.e. an enum).
They're completely different things.

You then need to understand what enums are - they're not things you
create instances of, they're just fixed sets of values. You don't
create new enumerations on the fly - an enumeration is a type in
itself.

Jon
 
Sorry using the wrong wording completely. I do understand where i was
becoming confusing i meant that i want to declare variables as follows based
on the enumeration:

public enum FilterType
{
}

FilterType filter1 = FilterType.None
FilterType filter2 = FilterType.None
.....
FilterType filtern = FilterType.None

where n = noOfFilters
 
b1uceree said:
Sorry using the wrong wording completely. I do understand where i was
becoming confusing i meant that i want to declare variables as follows
based
on the enumeration:

public enum FilterType
{
}

FilterType filter1 = FilterType.None
FilterType filter2 = FilterType.None
....
FilterType filtern = FilterType.None

where n = noOfFilters
Try this:

FilterType[] filters = new FilterType[n];
//Given your declaration of FiterType, the elements will allready be
FilterType.None

for (int i =0; i<n; i++)
{
fiters = ....
}


Christof
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top