Method Parameters.  Enumeration?

Posted on 2005-03-03
Medium Priority
Last Modified: 2008-01-09
This should be an easy one.  I have a class method, and I want to limit a parameter to one of two values.  Here's what I want:

Method TransferSpreadsheet(TransferType x);

When a programmer tries to call the TransferSpreadsheet method, and they are prompted to enter the TransferType parameter, I want the only two choices to be "Import", or "Export".  

Do I need an enumeration for this?  Can someone walk me through the steps?


Question by:ssteeves
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment

Accepted Solution

gena17 earned 200 total points
ID: 13448710
Hi, ssteeves.

I think you can use or enumeration or boolean type for this.
Boolean is simple - just pass TRUE or FALSE to the method.

Enumeration is simple too:
public enum TransferType

void TransferSpreadsheet(TransferType x)
  switch (x)
    case TransferType.Import:
      // do some stuff
    case TransferType.Export:
      // do some stuff

Hope this helps,


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question