.net - Can An Interface Contain An ENum

Jan 27, 2010

Can an Interface contain an Enum?I am using asp.net 2.0. Suddenly my code started having problems when I added an enum to the interface below. In it, LookUpType is an enum.

Public Interface ILookup
Property ID() As Int32
Property Text() As String

[code]....

View 1 Replies


ADVERTISEMENT

Create A Enum Or Enum Type Functionality Witch Return String (enum Returns Int) In .net

Dec 30, 2009

I have a URL lets say . some time i need to send HTTP and some time i need to send it to HTTPS for that i created a enum:

Private _protocol As Protocol

Enum Protocol
HTTP
HTTPS

[CODE]...

Now when i get value back from protocoltype it returns me integer value as enum do so tell me how to get string from enum or other substitute.

Dim targetUri As String = setting.protocolType & "://www.mysite.com"

View 1 Replies

Enum Item - Protected Name - Statement Cannot Appear Within An Enum Body

Mar 25, 2011

I'm trying to declare an enumeration and one of the names I'd like to use for an item is not usable apparently. Where I am declaring 'STEP = 3', I get this error message in visual studio: "Statement cannot appear within an Enum body. End of statement expected." Is it possible to use STEP as an item name somehow? [Code]

View 4 Replies

ENum Names And Values Don't Match For Same ENum

Jan 2, 2012

RE - FilesystemRights Enum

This Code:

Dim FSRS As Type = GetType(FileSystemRights)
For Each fsr As String In [Enum].GetNames(FSRS)
TextBox1.AppendText(fsr.ToString & vbCrLf)
Next

View 3 Replies

Nullable Enum Verse Enum.None?

May 26, 2010

Which is better, using a nullable enum or adding the value None=0 to your enum list?Using nullables requires more code, but I kind of like it since it forces me to think about the possibility. Otherwise I'm liable to forget about the None enum and fail to account for it being a special case.

View 11 Replies

Search An Enum Value Inside Of An Enum?

Aug 23, 2011

I've tried the code below but it always returns nothing, It should enter

Protected Function GetTotalDebitAmount(ByRef roEntryDetailRecordBaseList As List(Of PPDEntryDetailRecord)) As String
Dim iTotal As Integer = 0

[Code]....

I need some one who evaluate the part below:

If CBool(Array.IndexOf([Enum].GetValues(GetType(TransactionCodes.Debits)), CInt(oEntryDetailRecord.TransactionCode)) > 0) Then

View 1 Replies

Interface And Graphics :: Create A User Interface In A Game Such As The Application XFire Using VB?

Jan 12, 2010

how to create a user interface in a game such as the application XFire using Visual Basic?

View 3 Replies

Interface And Graphics :: Use A Graphical User Interface That Contains A Drag And Drop Form?

Oct 19, 2008

I'm working on a design project where I have to use a Graphical User Interface that contains a drag and drop form. It consists of having a window dropped on a wall. Both of them are images to scale. I would like to know what kind of code I would have to use to show the x and y coordinates of one of the points of my window when dragged so when I drop it, I'm dropping in it on the desired coordinate of the wall.

View 2 Replies

Interface And Graphics :: How To Procede With An Interface Design Approach

May 18, 2012

I was wondering if I could elicit some tips on how to procede with an interface design approach.That is. What is a good way to go about establishing a "work area" where one can have multiple "floating forms" in this area.Can you have a form which occupies the entire windows desk top and the other forms "float" in this space? the "floating" forms would need to interact with each other where pressing buttons etc on them would affect other forms on the "workspace") Or what would be a good way to start accomplishing that? Or is there a better way to get the same effect?

View 4 Replies

Interface And Graphics :: Link A Class / Object To An Interface?

Apr 21, 2010

I'm trying to make a .dll that contains a lot of basic functionality that a program can use. Currently i am trying to use interfaces to make a lot of this functionallity independend of the program using it but i hit a snag. The Basic idea is that a programmer will create his own object using the interface discribed in my .DLL file. Then implements those functions as he likes. He can then instanciate a controller (found in the same DLL) and sends his custom object implementing the interface to that Controller. The controller can then be started and will take over all the work. I do not know what type of object is send to the controller and idealy i want to program it in such a fashion that i shouldn't care as long as the object send implements that interface.In code I am trying to achieve the following: (quite simplyfied)

.Dll:
Code:
Public Interface MyInterface '<----Decleration of the interfaceFunction GetData() As Integer
Function SetData(Data As Integer)
end interface

[code]....

this propperly. I know that the second i set the interface adaptor in the Controller VS comes nagging that it can not be converted to a "MyInterface" Class. Obviously i am doing something wrong. I can change the datatype that the controller expects to the "MyController" type but that would completely ruin the whole idea of flexibillity. I am hoping someone sees what i am trying to do and can point out where i made the thinking error.

View 6 Replies

Interface And Graphics :: Picture Of Interface And Get Feedback On Changes For Easier Use?

May 21, 2012

Is this where i would post a picture of my interface and get feedback on changes for easier use? If not is there someplace on this forum or any other forum to do this?

View 1 Replies

C# - Structure Map - Registering Wrapper Of An Old Interface For A New Interface?

Nov 18, 2011

in the codebase i'm maintaining there is an old interface. Let's call it IFoo. It pretty much became obsolete and replaced with the Interface INewFoo with a change a few weeks ago, but for backwards-compatibility purposes, i wrote a wrapper class which implements INewFoo and takes an IFoo in the constructor.To clarify, consider the following code.

Public Interface IFoo
Sub DoStuff()
End Interface[code].....

For both interfaces, the implementations are loaded by scanning a few assemblies with StructureMap. Now, let's get to the bad things. Most implementations for the old interface were put into forms for reason i can neither understand nor change. Because those tend to be displayed and disposed, i have to create a new instance every time i use ObjectFactory.GetAllInstances(Of IFoo). Thats still no problem, but i'd like to register a INewFoo-Wrapper for each registered implementation of IFoo, so that i can just use ObjectFactory.GetAllInstances(of INewFoo) and get all implementations of IFoo AND INewFoo.I can't iterate through the implementations of IFoo and register a wrapper for each one because as far as i can see, you can just register those with instances.Wrong code below:

ObjectFactory.Configure(Sub(config)
config.Scan(Sub(scan)
For Each ass In assemblies[code].....

My question is: Is it possible to register a wrapper for each implementation of IFoo which always creates a new instance of the implementation before creating a new instance of the wrapper?

View 1 Replies

Declare A Property As An Interface Collection Of An Interface?

Feb 7, 2011

I want to declare a property as an interface collection of an interface, and I want to instanciate the explicit type later, in the constructor. Something like this.

Public Class LicenseFile
Implements ILicenseFile
Public Property Collection As IList(Of ILicenseFileDataNode)

[Code]....

In short, the question is "Why It Didn't work"? This is a simplified scenario, but It's easy to take a workarround, But I need understand the reason because It's fails.

View 2 Replies

Using Interface With Relay And Interface Is Connected To Computer?

Dec 17, 2009

I'm using interface with relay and interface is connected to computer on COM (serial) 9 pins port. In Visual Studio 2005 I'm using this

SerialPort1.Open
SerialPort1.DtrEnable = True
SerialPort1.Breakstate = True

[code].....

View 23 Replies

How Enum Is Used In .NET

Nov 25, 2009

How does enum work in .NET ?

eg.

Enum eOpenMode
Add = 1
Edit = 2
End Enum

[Code].....

How does this gets compared by their value(1,2) or by its name (add,edit) and what will be memory allocation scheme ?

View 4 Replies

How To Use IN In An Enum

Apr 13, 2011

I need to use IN in an EMUN.

-Public enum Talkers
-IN
-GP
-WI
-End Enum

View 2 Replies

Asp.net - VB Brackets In Enum?

Mar 24, 2011

I'm finding this in some legacy code and just curious what the brackets are for?

Public Enum myEnum
none = 0
abc = 2

[code]....

View 1 Replies

Decreasing Value In C# Or .NET Enum?

Apr 23, 2012

More for interest than actual need.is it possible to have an automatically decreasing enum in C# or VB.NET?

public enum testEnum
{
this = -1,
that,
other,
}

So that that = -2 and other = -3.I'm pretty sure the only way to do it is to specifically assign "that" and "other", but I wondered if there was an automatic way of doing it.

Edit To be clear, I'm simply talking about the automatic assignment of the value, not the actual value of the enum decreasing.

View 1 Replies

ENUM As Use It In Other Forms?

May 26, 2009

I'm using vb but still learning it. Here is the question, I have following ENUM created so that i can use it all the form. I created this Enum on my main form (startup form) and want to use in another form.

Enum MyStatus
Good = 1
Bad = 2
Normal = 3
End Enum

Now from other form I'm using it like frmMainmenu.MyStatus.red. I was wondering how i can make it public or create it in a way so that i don't need to give the prefix frmmainmenu before using its value.

View 1 Replies

Function For An Enum?

Mar 10, 2009

I have an enum like this:

Public Enum AssociateType
ALL
TIMED
COMMISSIONED
MANAGER
INVALID
End Enum

and I want to get a string based on the value of this enum:

Public Shared Function TypeToString(ByVal Type As AssociateType) As String
'Inputs: An AssociateType of the type of associate.
'Outputs: A string of the type of associate.

[Code]......

View 8 Replies

Get Enum Given Its Name (convert From C#)?

Oct 14, 2009

How do I do this C# statement in VB.Net (2005):MainMap.MapType =(MapType)comboBoxMapType.SelectedValue;MainMap only accepts Types so passing the Integer value of the type is not possible. The combo contains a list of strings:comboBoxMapType.DataSource = Enum.GetValues(typeof(MapType));In my case I need to limit the list to less than 100% of the Enum values so code similar to .Datasource= code will not work.So in general I need a way to return an enum given the name of the enum.Maybe I should just do a Collection of Enums (if that is even possible) and use the name as the Key?

View 2 Replies

The Right File Name For An Enum?

Aug 31, 2009

I have a DataType (text, numeric, date, boolean, money) enum and I need to put that in a file. How should I call the file and where in my DataAccessLayer.Generic namespace should I put the file into? Right now the file is called enum.vb and is in theDataAccessLayer.Generic.DataTypes namespace. The Result is ataAccessLayer.Generic.DataTypes.DataType, but it is misleading because the file is called enum.vb

View 2 Replies

VB Brackets In Enum?

Apr 22, 2009

I'm finding this in some legacy code and just curious what the brackets are for?

Public Enum myEnum
none = 0
abc = 2

[code].....

View 2 Replies

Why Does Enum Need To Use A CType

Mar 24, 2011

In vb.net, I got an Enum defined As Integer:
Enum enUtilityTypeDetailStudentEntryWorkflow As Integer
enUTDSEW_Default = 379

[code].....

This works but it adds a lot of noise to the code and it seems like the Enum is already defined as an Integer, making me think, why do I have to assign it again?

View 1 Replies

Working With Enum?

Feb 1, 2012

i have a list as an enum and when I want to select values as following, what is the best way to approach it

Public Enum ScanLocations
station1 = 1
station2 = 2
station3 = 3
station4 = 4
end enum

So if i have "station2" as a value in a textbox etc, and I click a button 'next' then it will give me "station3"if i click 'previous' then it will give me "station1"

View 2 Replies

Add Enum Entries During Runtime?

Jun 27, 2010

Is it possible to add Enum entries during runtime?

View 7 Replies

Alias An Enum - Shorter Name ?

Apr 3, 2012

I have an enum in one module that's used in another that has a long name:

Public Enum Enumwithaverylongname
foo
bar
end Enum

When I use it, I'd like to alias it to a shorter name like:

f.foo
instead of
Enumwithaverylongname.foo

Can I do that?

View 6 Replies

An Integer String In An Enum?

Oct 8, 2010

I know this is a proper enum:

Private Enum Months
JANUARY = 1
FEBRUARY = 2
...
End Enum

However, I want to have an enum where the string will solely be integers.

Example:

Private Enum ColumnCounts
01 = 5
02 = 4
03 = 40[code].....

Essentially, I didn't want to put the f in there, just wanted to do 01. The way this will be called is:

Select Case (nRecordType)
Case "01"
...
Case "02"[code].....

Because I'm not making an instance of it and not calling a constructor, there's no way to autopopulate a Dictionary.And I don't want to convert to integer so I'm not going to do an array. That is just in case eventually the value gets above 99 and the next value would be A0.I'm trying to think of easy future changes to this and backwards compatability.If you need more explanations, let me know.

Edit 2:This is what I've done now and I think it should work:

Public Class Part
Private Shared columnCounts As Dictionary(Of String, Integer) = New Dictionary(Of String, Integer)
Public Shared Function ValidateColumns(ByRef lstFiels As List(Of String)) As Boolean[code]....

I can't verify that it's going to do what I want to, but it doesn't give me an error when I build it so I'm crossing my fingers.

View 6 Replies

Convert Integer To Value From Enum?

Feb 4, 2011

I have add some items into an combbox, the items represent the values from ContentAlignment Enum, (the values of the combobox are not same as the values of the Enum)

Upon selection of a value from the combobox, i want to set the TextAlignment of the Button

View 3 Replies

Difference Between Enum And Constant?

May 13, 2009

What's the difference between enum and constant?Are they useful in real-life programming? or do they exist solely to make coding more tidy? Do they serve any real purpose?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved