473,382 Members | 1,583 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Enumerator question


Hello,
I have methods which refer to some class enumerator .Should I make it
pulic or encapsulate it?

*** Sent via Developersdex http://www.developersdex.com ***
Dec 14 '06 #1
7 1782
Hi,

What do you mean exactly? (some code samples might help)

--
Dave Sexton

"csharpula csharp" <cs*******@yahoo.comwrote in message
news:%2******************@TK2MSFTNGP03.phx.gbl...
>
Hello,
I have methods which refer to some class enumerator .Should I make it
pulic or encapsulate it?

*** Sent via Developersdex http://www.developersdex.com ***

Dec 15 '06 #2
Hi,

What do you mean exactly? (some code samples might help)

--
Dave Sexton

"csharpula csharp" <cs*******@yahoo.comwrote in message
news:%2******************@TK2MSFTNGP03.phx.gbl...
>
Hello,
I have methods which refer to some class enumerator .Should I make it
pulic or encapsulate it?

*** Sent via Developersdex http://www.developersdex.com ***

Dec 15 '06 #3
I'm not sure what you mean by this either. But, the typical pattern is
to make the enumerator private to its containing class and publish the
interface through a method call.

Brian

csharpula csharp wrote:
Hello,
I have methods which refer to some class enumerator .Should I make it
pulic or encapsulate it?

*** Sent via Developersdex http://www.developersdex.com ***
Dec 15 '06 #4

Hello,I will try to explain my problem:

Have an executable which can activate one of 2 silngeltones.
I need an enumerator in order to let the mrethods inside singletone know
if they were activated from executable or maybe from some other place.
I prefer no to path this enumarator in sigeltone methods arguments.
How can I do it?
Thanks
*** Sent via Developersdex http://www.developersdex.com ***
Dec 16 '06 #5
Hi,
Have an executable which can activate one of 2 silngeltones.
I think you mean "singleton" :)
I need an enumerator in order to let the mrethods inside singletone know
if they were activated from executable or maybe from some other place.
By "enumerator" do you mean "enum"?

You have to be clear about this since they are two very different things,
although using an enumerator for the described behavior doesn't make sense.
An enumerator is used to iterate over a collection. An enum (enumeration)
is a type that you can define to contain named integral constants. You can
define an enum like this:

public enum Vehicle
{
Car, // = 0
Truck, // = 1
Boat, // = 2
Plane // = 3
}

You don't have to but you can assign each constant a numeric value if
desired. If you're using FlagsAttribute on your enum then you'll probably
want to assign each constant to a distinct value that is bit aligned (to
serve as bit flags):

[Flags]
public enum Vehicles // note the pluralization (s) to indicate Flags
{
None = 0,
Car = 1,
Truck = 2,
Boat = 4,
Plane = 8,

ByLand = Car | Truck // = 3
}

You probably won't need to use flags but I included an example anyway for
the sake of completeness. To use the first (non-flags) enum you can pass
one of its values to a method like this:

void CallMyMethod()
{
MyMethod(Vehicle.Car);
}

void MyMethod(Vehicle vehicle)
{
Console.WriteLine(vehicle); // writes Car
}

For more info:

"C# Programmer's Reference, enum (C# Reference)"
http://msdn2.microsoft.com/en-us/library/sbbt4032.aspx
I prefer no to path this enumarator in sigeltone methods arguments.
I don't understand what you mean here. Could you please clarify this
requirement?

--
Dave Sexton
Dec 16 '06 #6
Yes,it's enum and I wanted to know what is the best way to desin this
scenario?

*** Sent via Developersdex http://www.developersdex.com ***
Dec 16 '06 #7
Hi,

But I asked for clarification at the end of my last post because it's still
not clear what your scenario actually is and what you need help with.

--
Dave Sexton

"csharpula csharp" <cs*******@yahoo.comwrote in message
news:ub**************@TK2MSFTNGP03.phx.gbl...
Yes,it's enum and I wanted to know what is the best way to desin this
scenario?

*** Sent via Developersdex http://www.developersdex.com ***

Dec 16 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Gordon Rundle | last post by:
It drives me nuts that I can't use foreach with an enumerator instance. I would like the following to be functionally identical: foreach (Object o in MyCollection) ... foreach (Object o in...
7
by: tony collier | last post by:
if i have a string eg string day="monday"; and an enumerator enum days {monday=0,tuesday, wednesday}
2
by: Stephanie Stowe | last post by:
Hi. I am trying to understand the weird System.DirectoryServices object model. I have a DirectoryEntry object. I want to enumerate through the PropertyCollection. So I looked at GetEnumerator....
11
by: rawCoder | last post by:
Hi, Which is better in terms of performance. Iterating over Enumerator ForNext loop (using indexer) ForEach loop Thanx rawCoder
18
by: Rob Panosh | last post by:
Hello, When traversing an ArrayList which is faster? For Each oItem as Something in me.ArrayList ..... ..... Next OR
5
by: toldyouso | last post by:
The following script works in IE but in Firefox errors with the msg Enumerator is not defined. <html> <head> <meta name="vs_defaultClientScript" content="JavaScript"> <script...
3
by: ajmastrean | last post by:
I have a bunch of enumerators. I need to pass them into a function that is designed to write all values of any enumerator to the console. For instance... public enum Days : int { Sunday = 1,...
6
by: Michael C | last post by:
I'm reading about Iterators and the article I'm reading states that an enumerator must load all of the objects into memory, which is obviously a big waste if there are a large number of objects and...
3
by: Dave | last post by:
I'm calling string.Split() producing output string. I need direct access to its enumerator, but would greatly prefer an enumerator strings and not object types (as my parsing is unsafe casting...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.