Can you clarify something -- you mentioned an IAnimal, which to me implies
an interface -- which has no implementation, so I don't see where there's
room for fxcop to suggest use of a property.
But looking at what you've written below, the set accessor in the code you
gave is effectively a no-op as it just assigns a value to itself.
Try to follow this pattern (note capitalization):
private ushort port;
public ushort Port
{
get { return this.port; }
set { this.port = value; }
}
Note the use of 'this.' even where it's not technically needed (thus does
'this.' function much as the 'm_' or whatever from the days of old). If you
get into this habit, you will help avoid errors and make your code easier to
read.
Are you saying that the above code would cause fxcop to warn on
public void FuncA(ushort port) {}
as a class method? Seems odd if that's the case.
"Chua Wen Ching" <ch************@nospam.hotmail.com> wrote in message
news:90**********************************@microsof t.com...
Hi Tamir Khason,
This is what i normally will do.
private ushort port;
public ushort Port
{
get { return port; }
set { this.port = port; }
}
public void CallFuncA(ushort port) {}
---
Does it means, now i just ignore the code above and just do this:
private ushort port;
public void CallFuncA(ushort Port) {}
Just to confirm. Thanks again.
--
Regards,
Chua Wen Ching :)
"Tamir Khason" wrote:
You have here ambiguous variable name (port). Try not to use the same
name for external and internal variables. eg. change you function to "public
void CallFuncA(ushort Port);" This should solve the problem
--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
"Chua Wen Ching" <ch************@nospam.hotmail.com> wrote in message
news:49**********************************@microsof t.com... I had use fxcop to check my code. I had 1 confusion here.
I would normally call a method by this way in my IAnimal:
Example:
public void CallFuncA(ushort port);
But fxcop says i need to write like a property rather than method to
this:
public void CallFuncA(ushort port)
{
this.port = port;
}
Any idea? Is it a must and best practices for us to follow what fxcop
says? I had so many errors in there. Sigh... i didn't know i code so
bad. :( --
Regards,
Chua Wen Ching :)