473,386 Members | 1,846 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,386 software developers and data experts.

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 2531
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

8
by: manan.kathuria | last post by:
hi all , the expression in question is ++i&&++j||++k most sources say that since the result of the || operation is decided by the LHS itself , the right side is not computed my point of...
0
by: mikeon | last post by:
Hello! I have an aspx page with 4 images on it: <img src="<%# ImageUrl %>" /> <img src="x<%# ImageUrl %>" /> <img src="<%# ImageUrl %>" runat="server" ID="Img1"/> <img src="x<%# ImageUrl %>"...
0
by: Paul [Paradise Solutions] | last post by:
Hi all Was wondering of anyone can help me with why the following expression works as expected in XMLSpy, but does not in VB.net: {1,2}?? {2}|GIR 0AA$ IN VB.net using Regex.IsMatch, all...
7
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I...
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...
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...
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...
1
by: Rick | last post by:
I'm in the process of migrating from VS 2003 to VS 2005. One of the compile warnings I am seeing is: "Access of shared member, constant member, enum member or nested type through an instance;...
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...
3
by: GODSPEEDELECTRONICS | last post by:
My database is simple. It has a table that tracks customers, with they're name, address, etc. I have a price list table that contains "iteminstall" , "price", and "qty" and I have a payment...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.