473,545 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I get rid of "warning CS0649 : field is never assigned to"

I have a series of class variables that are assigned to through
reflection. Every time I compile one of these classes I get this
warning :

warning CS0649: Field 'xxx' is never assigned to, and will always have
its default value null

Is there any way I can supress this warning? I have a custom attribute
applied to each field, which the binder uses, and am explicitly
assigning to null. I would like to remove the '=null;' if I can.

[BindMe] protected TextBox theText = null;

ASP.Net pages do not have this problem when you place controls on them,
so I think this may be possible. The only post addressing this
directly is from 2002, and in this group.

I was hoping for something like [CompilerDisable Warning(649)] that I
could apply to my custom attributes.

Thanks for any help,
- Andrew Backer

Nov 17 '05 #1
2 19332
Andrew Backer wrote:
I have a series of class variables that are assigned to through
reflection. Every time I compile one of these classes I get this
warning :

warning CS0649: Field 'xxx' is never assigned to, and will always have
its default value null

Is there any way I can supress this warning? I have a custom attribute
applied to each field, which the binder uses, and am explicitly
assigning to null. I would like to remove the '=null;' if I can.

[BindMe] protected TextBox theText = null;

ASP.Net pages do not have this problem when you place controls on them,
so I think this may be possible. The only post addressing this
directly is from 2002, and in this group.

I was hoping for something like [CompilerDisable Warning(649)] that I
could apply to my custom attributes.

Thanks for any help,
- Andrew Backer

not sure for c#, but in visual c you can #pragma disable warning(CS0649)
I don't remember the syntax, but that's the idea...

you may try to look up how to do that in c#

marcel
Nov 17 '05 #2
Yes, there is something similar for c#, I think you even have the
syntax correct :)

I don't want to stick pragmas like that in each class that does this,
though. The current work aorund is to just assign = null.

I am hoping that there is some language/framework feature that will let
me disable this warning in much the same way custom attributes work. I
could then combine my attribute with this base, and be able to ignore
individual fields by tagging them...

[BindMe]
[IgnoreWarning(9 64)]
protected TextBox myField;

[BindMeAndIgnore Warnings]
protected TextBox myField;

There must be a clever way to do this, since aspx pages do it. Perhaps
there is some other detail that I am missing that makes this not apply?
Any smartie from MS have any clues?

- Andrew

Nov 17 '05 #3

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

Similar topics

0
1671
by: H. S. | last post by:
Hi, I am trying to compile the examples in arpack++ library on x86 Linux (flavor of Red Hat) running 2.4.24 kernel and g++ (3.2 20020903 version). Here is part of the compiler error I am getting. If needed, I can give complete error output: #---------------------------------------- /home/red/include/arpack++/include/arlsnsym.h: In...
2
6053
by: Lateralus | last post by:
headers/vector3.h: In member function ‘Vector3 Vector3::operator*(Scalar)’: headers/vector3.h:13: error: no matching function for call to ‘Vector3::Vector3(Vector3)’ ‘Vector3::Vector3(Vector3)’ headers/vector3.h:10: note: candidates are: Vector3::Vector3(Vector3&) I'm a little confused as to what my problem is. I get this error...
2
2015
by: MLH | last post by:
I have a form that ALWAYS prompts me as to whether I want to save the changes - every time I open it in design view - even if I don't make ANY changes. Why might that be?
1
3690
by: Hans Nieser | last post by:
I was wondering wether it was normal that I get "field is never assigned to" warnings after defining a struct but not having actually referred to it in my code yet. Is this just something I'll have to ignore or am I doing something wrong here? TIA
7
16810
by: Olaf Baeyens | last post by:
I am testing VC++ 2005 and I get this warning: "warning C4996: 'strncpy' was declared deprecated" Does that mean that they might be phased out in VC++ 2006 or higher? Or does an alternative function exist as replacement?
4
1737
by: Steven | last post by:
Hi all, I have a solution with a VB.net project, and a installer-project. When I build the solution, I get the following message; WARNING: Language ID '0' not supported. To the installer project, I added the option to check for the ..net framework. If not present, it will install dotnetfx.exe. Could this have something to do with this...
19
7908
by: lawrence k | last post by:
How can I find out where my script is outputting to the screen for the first time? My error logs are full of stuff like this: PHP Warning: session_start(): Cannot send session cache limiter - headers already sent in /home/httpd/vhosts/monkeyclaus.org/httpdocs/media/audio/pdsIncludes/CommandStartSession.php on line 14
3
1817
by: neolempires2 | last post by:
hi..i'm new in sql progaming, i try to make make a query that in table field "match" return to "1" if no member record in another table and return to "0" if there is any record member : ex table member: member id A 12 B 14
2
12055
by: Fresh | last post by:
Hi, I met a problem, when I change warning level to 4 and to track warning as error, then a link warning show "warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification" I change the INCREMENTAL to default, then warnings disappeared, but I'm not sure if it is the correct solution. Any suggestion?
0
7475
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7664
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7921
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5982
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5343
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4958
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1900
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1023
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
720
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.