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

object reference

Ray
I am starting to realize that there are differences in vb.net and c#:
in terms of syntax, object and keyword in small or big letter

In the routine below, I got this error message in c
An object reference is required for the nonstatic field, method, or property 'System.Web.UI.Page.MapPath(string)

But I would not get an error messaage if this same code is converted in vb. Please help. I am new in c#

private static void getnow(string dfilename)
XmlDocument docc = new XmlDocument()
docc.Load(MapPath( string.Concat("/virtualdirectory/", dfilename)))
....
Ray
Jul 21 '05 #1
4 1899
C# is case-sensitive, VB.NET is not. So in C# "var" and "VAR" and "vAr" are
three different things, but in VB.NET they're the same.
--
____________________
Klaus H. Probst, MVP
http://www.vbbox.com/

"Ray" <an*******@discussions.microsoft.com> wrote in message
news:38**********************************@microsof t.com...
I am starting to realize that there are differences in vb.net and c#:
in terms of syntax, object and keyword in small or big letters

In the routine below, I got this error message in c#
An object reference is required for the nonstatic field, method, or property 'System.Web.UI.Page.MapPath(string)'
But I would not get an error messaage if this same code is converted in vb. Please help. I am new in c#.
private static void getnow(string dfilename) {
XmlDocument docc = new XmlDocument();
docc.Load(MapPath( string.Concat("/virtualdirectory/", dfilename)));
....
}

Ray

Jul 21 '05 #2
Ray
Just remove the static wor
It will work because it is no longer a constan

private void getnow(
instead of private static void hetnow()
Jul 21 '05 #3
Cor
Hi Ray,

As addition to Klaus,

VB is case insensitive but the VB.net IDE set it automaticly for you in the
propercase as expected (if it are no sentences between "") and therefore
you would probably not have so much problems with converting.

I hope this helps,

Cor
Jul 21 '05 #4
Ray <an*******@discussions.microsoft.com> wrote:
I am starting to realize that there are differences in vb.net and c#:
in terms of syntax, object and keyword in small or big letters

In the routine below, I got this error message in c#
An object reference is required for the nonstatic field, method,
or property 'System.Web.UI.Page.MapPath(string)'

But I would not get an error messaage if this same code is converted
in vb. Please help. I am new in c#.

private static void getnow(string dfilename) {
XmlDocument docc = new XmlDocument();
docc.Load(MapPath( string.Concat("/virtualdirectory/", dfilename)));
....
}


Yes you would - or rather, you'd get:

Cannot refer to an instance member of a class from within a shared
method or shared member initializer without an explicit instance of the
class.

"static" here is the equivalent of "shared"

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #5

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

Similar topics

6
by: Chris S. | last post by:
I'm trying to make a graphical editor and browser for Pickled files. One aspect I'm not sure about is how to detect multiple references to the same data. For instance, say I had the Pickled...
28
by: Daniel | last post by:
Hello =) I have an object which contains a method that should execute every x ms. I can use setInterval inside the object construct like this - self.setInterval('ObjectName.methodName()',...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
29
by: web1110 | last post by:
If I have 2 variables, A and B, referencing the same object and then do a A.Dispose(), what happens to B?
5
by: Michael Moreno | last post by:
Hello, In a class I have this code: public object Obj; If Obj is a COM object I would like to call in the Dispose() method the following code: ...
16
by: anonymous.user0 | last post by:
The way I understand it, if I have an object Listener that has registered as a listener for some event Event that's produced by an object Emitter, as long as Emitter is still allocated Listener...
7
by: TS | last post by:
I was under the assumption that if you pass an object as a param to a method and inside that method this object is changed, the object will stay changed when returned from the method because the...
3
by: User1014 | last post by:
A global variable is really just a property of the "Global Object", so what does that make a function defined in the global context? A method of the Global Object? ...
2
by: Ralph | last post by:
Hi I don't understand why it's not working: function schedule(imTop){ this.tdImagesTop = imTop; } schedule.prototype.selectEl = function() { alert(this.tdImagesTop);
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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.