473,473 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

qualifying expression will not be evaluated

Ben
Hi,

i would like to have an explanation about this:
This works, but i get the message in code-behind:
access of shared member,... or nested type through an instance; qualifying
expression will not be evaluated.

Dim cl As System.Drawing.Color
Label1.ForeColor = cl.FromName(DropDownList1.SelectedValue)

<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack=true>
<asp:ListItem Text="red" Value="red"></asp:ListItem>

By the way, i know that there is another solution:
System.Drawing.Color.Fromname(DropDownList1.Select edValue).

Thanks
Ben
Jun 22 '07 #1
5 1375
On Jun 22, 1:22 pm, "Ben" <b@bnwrote:
Hi,

i would like to have an explanation about this:
This works, but i get the message in code-behind:
access of shared member,... or nested type through an instance; qualifying
expression will not be evaluated.

Dim cl As System.Drawing.Color
Label1.ForeColor = cl.FromName(DropDownList1.SelectedValue)

<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack=true>
<asp:ListItem Text="red" Value="red"></asp:ListItem>

By the way, i know that there is another solution:
System.Drawing.Color.Fromname(DropDownList1.Select edValue).

Thanks
Ben
By the way, i know that there is another solution:
System.Drawing.Color.Fromname(DropDownList1.Select edValue).
Won't using that take away the error?

Thanks,

Seth Rowe

Jun 22 '07 #2
Ben
I would like an explanation about the fact i get that error and nevertheless
it works. What does that error mean?
i mentioned that there is a solution without error in order to avoid that i
get that solution as answer on my post.
"rowe_newsgroups" <ro********@yahoo.comschreef in bericht
news:11**********************@n60g2000hse.googlegr oups.com...
On Jun 22, 1:22 pm, "Ben" <b@bnwrote:
>Hi,

i would like to have an explanation about this:
This works, but i get the message in code-behind:
access of shared member,... or nested type through an instance;
qualifying
expression will not be evaluated.

Dim cl As System.Drawing.Color
Label1.ForeColor = cl.FromName(DropDownList1.SelectedValue)

<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack=true>
<asp:ListItem Text="red" Value="red"></asp:ListItem>

By the way, i know that there is another solution:
System.Drawing.Color.Fromname(DropDownList1.Selec tedValue).

Thanks
Ben

>By the way, i know that there is another solution:
System.Drawing.Color.Fromname(DropDownList1.Selec tedValue).

Won't using that take away the error?

Thanks,

Seth Rowe

Jun 22 '07 #3
"Ben" <b@bnschrieb:
>I would like an explanation about the fact i get that error and
nevertheless it works. What does that error mean?
i mentioned that there is a solution without error in order to avoid that
i get that solution as answer on my post.
'FromName' is a shared member of 'Color'. Thus it's not necessary to call
it on an instance. It can be called on the type directly ('... =
Color.FromName(...)'). The compile-time error does not make much sense in
your simple scenario, but it would if you replace the part on the left hand
side of the '.' by a function call, for example ('... =
GetColor().FromName(...)'). In this case, 'GetColor' won't get called
because the compiler will only emit a call to 'Color.FromName'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jun 23 '07 #4
On Jun 22, 3:15 pm, "Ben" <b@bnwrote:
I would like an explanation about the fact i get that error and nevertheless
it works. What does that error mean?
i mentioned that there is a solution without error in order to avoid that i
get that solution as answer on my post.

"rowe_newsgroups" <rowe_em...@yahoo.comschreef in berichtnews:11**********************@n60g2000hse.g ooglegroups.com...
On Jun 22, 1:22 pm, "Ben" <b@bnwrote:
Hi,
i would like to have an explanation about this:
This works, but i get the message in code-behind:
access of shared member,... or nested type through an instance;
qualifying
expression will not be evaluated.
Dim cl As System.Drawing.Color
Label1.ForeColor = cl.FromName(DropDownList1.SelectedValue)
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack=true>
<asp:ListItem Text="red" Value="red"></asp:ListItem>
By the way, i know that there is another solution:
System.Drawing.Color.Fromname(DropDownList1.Select edValue).
Thanks
Ben
By the way, i know that there is another solution:
System.Drawing.Color.Fromname(DropDownList1.Select edValue).
Won't using that take away the error?
Thanks,
Seth Rowe
It's fairly simple - In your code cl is an instance of the color
class. FromName is a shared method of the Color class which means that
cl also has the method. Since shared methods can't be used with
instance the compiler will just ignore the instance (cl) and go
directly to the class (System.Drawing.Color). This means the "will not
be evaluated" error is talking about the instance and not the method -
that's why the expression still works. As for why the warning is even
generated I'm not sure - perhaps to prevent someone from making a
pointless variable when they should just call the method directly (you
know, like you did in your code :-) )

Thanks,

Seth Rowe

Jun 23 '07 #5
Ben
That are what i call good explanations and to the point.
Thanks to both

"rowe_newsgroups" <ro********@yahoo.comschreef in bericht
news:11**********************@m37g2000prh.googlegr oups.com...
On Jun 22, 3:15 pm, "Ben" <b@bnwrote:
>I would like an explanation about the fact i get that error and
nevertheless
it works. What does that error mean?
i mentioned that there is a solution without error in order to avoid that
i
get that solution as answer on my post.

"rowe_newsgroups" <rowe_em...@yahoo.comschreef in
berichtnews:11**********************@n60g2000hse. googlegroups.com...
On Jun 22, 1:22 pm, "Ben" <b@bnwrote:
Hi,
>i would like to have an explanation about this:
This works, but i get the message in code-behind:
access of shared member,... or nested type through an instance;
qualifying
expression will not be evaluated.
>Dim cl As System.Drawing.Color
Label1.ForeColor = cl.FromName(DropDownList1.SelectedValue)
><asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack=true>
<asp:ListItem Text="red" Value="red"></asp:ListItem>
>By the way, i know that there is another solution:
System.Drawing.Color.Fromname(DropDownList1.Selec tedValue).
>Thanks
Ben
>By the way, i know that there is another solution:
System.Drawing.Color.Fromname(DropDownList1.Selec tedValue).
Won't using that take away the error?
Thanks,
Seth Rowe

It's fairly simple - In your code cl is an instance of the color
class. FromName is a shared method of the Color class which means that
cl also has the method. Since shared methods can't be used with
instance the compiler will just ignore the instance (cl) and go
directly to the class (System.Drawing.Color). This means the "will not
be evaluated" error is talking about the instance and not the method -
that's why the expression still works. As for why the warning is even
generated I'm not sure - perhaps to prevent someone from making a
pointless variable when they should just call the method directly (you
know, like you did in your code :-) )

Thanks,

Seth Rowe

Jun 23 '07 #6

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

Similar topics

39
by: | last post by:
I am trying to run the following agregate function in a parameterized query on Access2000: Min(.*sqr(./.)/) The query saved OK, but an attempt to run it results in the message: The expression...
3
by: Jason luo | last post by:
Hi all, In c99-standard page 52,there is a sentence about void,as below: If an expression of any other type is evaluated as a void expression, its value or designator is discarded. I don't...
6
by: Suresh Jeevanandam | last post by:
Dear all, I read in "Python in a Nutshell" that when we have multiple assignments made on a single line, it is equivalent to have those many simple assignments and that the right side is evaluated...
19
by: Babis Haldas | last post by:
i have if(i==1 && func1() ) do something if i!=1 , func1 doesnt run at all this is in my compiler is this because the compiler or because the stantard can i rely that in any system...
21
by: Steven T. Hatton | last post by:
I'm trying to improve my formal understanding of C++. One significant part of that effort involves clarifying my understanding of the vocabulary used to describe the language. This is from the...
3
by: bumwipe | last post by:
I am trying to create a program that takes string expressions and solves them mathematically (i.e. string "5 + 4 * 2" will evaluate as 13). i have this much of the program made, but I am not sure...
32
by: silpau | last post by:
hi, i am a bit confused on expression evaluation order in expressions involving unary increment.decrement operators along with binary operators. For example in the following expression x...
5
by: Ben | last post by:
Hi, i would like to have an explanation about this: This works, but i get the message in code-behind: access of shared member,... or nested type through an instance; qualifying expression will...
5
by: Jeff Bean | last post by:
I need to compute a 64 bit file offset which will get passed to the _lseeki64 function. The inputs to the offset calculation are all unsigned shorts or unsigned longs. For example: unsigned...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.