Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

public interface myPlug
{
	void Initialize(test.IHost host);
	readonly string Name();
	void Go(object[] objs);
}

 

blue squiggly on 'Name'

"The modifier 'readonly' is not valid for this item"

 

Why? what's wrong with this?

 

i feel small

Brandon

i'm not lazy i'm just resting before i get tired.
Posted
public interface myPlug
   {
       void Initialize(test.IHost host);
       readonly string Name();
       void Go(object[] objs);
   }

 

blue squiggly on 'Name'

"The modifier 'readonly' is not valid for this item"

 

Why? what's wrong with this?

 

i feel small

Brandon

 

if I understand correctly want you really want is a read only property in your interface. . .

 

public interface myPlug
{
	void Initialize(test.IHost host);
	string Name { get{} };
	void Go(object[] objs);
}

Joe Mamma

Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.

Posted

thansk for you your help... i figured it out after some more time

i just used a function instead of a readonly property... DOH!

i'm not lazy i'm just resting before i get tired.
Posted
thansk for you your help... i figured it out after some more time

i just used a function instead of a readonly property... DOH!

yes that will work. . .

 

but the convention for Name is a property. . .

 

 

I mean you dont execute

 

string s = myObj.Name();

 

do you?

 

usually it is

 

string s = myObj.Name;

 

just a matter of style

Joe Mamma

Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.

Posted

public interface myPlug
   {
       void Initialize(test.IHost host);
       string Name { get{} };
       void Go(object[] objs);
   }

 

joe i was not allowed to create a readonly property this way for Name.

there has to be a way to do it... arrrg

 

thanks

brandon

i'm not lazy i'm just resting before i get tired.
Posted

it wont' allow the semicolon... if i remove that, well it obviously doesn't work in my interface

 

... what's the deal?

 

thanks for the help

brandon

i'm not lazy i'm just resting before i get tired.
Posted

The proper code is as follows:

 

[b][size=2][color=#0000ff]public [/b][/color][/size][size=2][color=#ff0000]interface [/color][/size][size=2][color=#000000]myPlug[/color]
[/size][size=2][color=#006400]{

[/color][/size][size=2][color=#ff0000]void [/color][/size][b][size=2][color=#191970]Initialize[/b][/color][/size][size=2][color=#006400]([/color][/size][size=2][color=#000000]test[/color][/size][size=2][color=#006400].[/color][/size][size=2][color=#000000]IHost host[/color][/size][size=2][color=#006400]);

[/color][/size][size=2][color=#ff0000]string [/color][/size][size=2][color=#000000]Name [/color][/size][size=2][color=#006400]{[/color][/size][size=2][color=#8b4513]get[/color][/size][size=2][color=#006400];}

[/color][/size][size=2][color=#ff0000]void [/color][/size][b][size=2][color=#191970]Go[/b][/color][/size][size=2][color=#006400]([/color][/size][size=2][color=#ff0000]object[/color][/size][size=2][color=#006400][] [/color][/size][size=2][color=#000000]objs[/color][/size][size=2][color=#006400]);

}[/color][/size]

 

This is as reference from the MSDN documentation at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vcrefTheInterfaceType.asp

"Programmers are tools for converting caffeine into code."

 

Madcow Inventions -- Software for the Sanity Challenged.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...