473,405 Members | 2,300 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,405 software developers and data experts.

C# enum and weird The private field 'SI.BitTorrent.Peer.clientChokeStatus' is never used error

I got private ChokeStatus clientChokeStatus;.
In the constructor i got clientChokeStatus = ChokeStatus.Choked; and it is
also used in a few other methods, but it keeps bitching The private field
'SI.BitTorrent.Peer.clientChokeStatus' is never used.
Nov 16 '05 #1
3 1781
It is used, is not it? But it throws that warning/error.

namespace Test
{

class Tester
{
public static void Main()
{
Foo f = new Foo(null, 5);
f.Foobish();
}
}

enum Foobar
{
Item1,
Item2
};

public class Foo
{
Foobar foobar;

public Foo(string foo, int bar)
{
foobar = Foobar.Item1;
}

public void Foobish()
{
foobar = Foobar.Item2;
}
}
}
Nov 16 '05 #2

"SpookyET" <no****@hotmail.com> wrote in message
news:opr7hzt3bi1s9n15@saturn...
It is used, is not it? But it throws that warning/error.

namespace Test
{

class Tester
{
public static void Main()
{
Foo f = new Foo(null, 5);
f.Foobish();
}
}

enum Foobar
{
Item1,
Item2
};

public class Foo
{
Foobar foobar;

public Foo(string foo, int bar)
{
foobar = Foobar.Item1;
}

public void Foobish()
{
foobar = Foobar.Item2;
}
}
}


A field is only considered used when readable. In this case you are simply
assigning to it, which is as good as a noop if the field is never read
from(the value in it doesn't matter to control flow, its just memory sitting
somewhere). I would assume you would want to expose the ChokeStatus
externally, in which case you should expose a property, or you have a use
for it internally somewhere, in which case you should ignore it until you
get around to checking it. If you are just tracking it so you can use it for
whatever purposes later, you can safely ignore this warning as well.
Nov 16 '05 #3
God, what I was thinking? You are right, and I knew this. ~3000 lines of
code gets you tired, confused, and unable to see simple things. I got rid
of some stuff, and now it is under 2000 LOC. I have fixed it. I have
forgot to add those methods because events are raised when a message of
being choked or interested is received/sent.

public bool IsClientChoked() {}
public bool IsPeerChoked() {}
public bool IsClientInterested() {}
public bool IsPeerInterested() {}

On Wed, 5 May 2004 00:16:09 -0500, Daniel O'Connell [C# MVP]
<onyxkirx@--NOSPAM--comcast.net> wrote:

"SpookyET" <no****@hotmail.com> wrote in message
news:opr7hzt3bi1s9n15@saturn...
It is used, is not it? But it throws that warning/error.

namespace Test
{

class Tester
{
public static void Main()
{
Foo f = new Foo(null, 5);
f.Foobish();
}
}

enum Foobar
{
Item1,
Item2
};

public class Foo
{
Foobar foobar;

public Foo(string foo, int bar)
{
foobar = Foobar.Item1;
}

public void Foobish()
{
foobar = Foobar.Item2;
}
}
}


A field is only considered used when readable. In this case you are
simply
assigning to it, which is as good as a noop if the field is never read
from(the value in it doesn't matter to control flow, its just memory
sitting
somewhere). I would assume you would want to expose the ChokeStatus
externally, in which case you should expose a property, or you have a use
for it internally somewhere, in which case you should ignore it until you
get around to checking it. If you are just tracking it so you can use it
for
whatever purposes later, you can safely ignore this warning as well.


--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 16 '05 #4

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

Similar topics

8
by: spoordp | last post by:
I'm rather new to C++, but I'm quickly learning. Anytime I don't know why something happens, I have to find out. Here is one that has stumped me. I wanted to declare an array with a constant...
21
by: Andreas Huber | last post by:
Hi there Spending half an hour searching through the archive I haven't found a rationale for the following behavior. using System; // note the missing Flags attribute enum Color {
1
by: Jim Hart | last post by:
Hi all! Can anyone explain this one to me. . . I have a 'Util' namespace with a 'Common' class that contains consts & values I use throughout multiple projects. One of the members of this...
10
by: Gandalf | last post by:
Hi, I created a C# application which is using many private variables. I'm working on VS .NET 2003 and have the following error (whereas the variable is used in the method of the class !) : ...
34
by: Steven Nagy | last post by:
So I was needing some extra power from my enums and implemented the typesafe enum pattern. And it got me to thinking... why should I EVER use standard enums? There's now a nice little code...
2
by: Dale Sampson | last post by:
My app uses an ODBC connection for a .mdb file. I want the app to create the source if it does not already exist (I copy a blank .mdb file to the users data store if it doesn't exist). I see how...
3
by: Ollie | last post by:
Ok, I am thinking of developing an open source Bit Torrent Tracker in C# ASP.NET as there are lots of php versions but no ASP.NET Before I get going I have a few questions... Anyone got any...
6
by: Studlyami | last post by:
Okay here's what i got. class A { . . . private: enum Type { A, B, C,
10
by: Doug | last post by:
I have an enum that will look kind of like this: private enum MyEnum { SomeValue = 0, AnotherValue = 1, ThirdValue = 2 }
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.