Scope of properties

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to make the get method of a property public, but the set method
internal so that it is effectively read-only outside the assembly but
read-write within it (sort of the nearest thing to a C++ "friend"), is this
possible? Or is there some way of achieving the "friend" effect?
 
Dave said:
I would like to make the get method of a property public, but the set
method
internal so that it is effectively read-only outside the assembly but
read-write within it (sort of the nearest thing to a C++ "friend"), is this
possible? Or is there some way of achieving the "friend" effect?

This is possible to do in C# 2, like this:

public int MyProperty {
get {
return val;
}
internal set {
val = value;
}
}

If you don't use C# 2, I'd suggest you use an internal setter method (as
opposed to the property setter) instead.


Oliver Sturm
 
Ah, that's interesting. Pardon my ignorance, but what is C# 2?

I have VS.NET 2003 (aka VS7.0) and .NET 1.1. I know that VS is now at 2005
(beta) and that .NET will shortly be at 2.0, codenamed "Longhorn", or is it
"Whidbey", no, hang on "Indigo", or was it "Yukon" - oh boy, you can see I'm
getting confused.

Clarification would be greatly appreciated.
 
Dave said:
Ah, that's interesting. Pardon my ignorance, but what is C# 2?

I have VS.NET 2003 (aka VS7.0) and .NET 1.1. I know that VS is now at 2005
(beta) and that .NET will shortly be at 2.0, codenamed "Longhorn", or is it
"Whidbey", no, hang on "Indigo", or was it "Yukon" - oh boy, you can see
I'm
getting confused.

These are a lot of very different things you mention :-)

C# 2 is the version that will be released with the upcoming VS.NET 2005
(and is now available in betas and various CTPs). It coincides with the
version of the .NET framework that's associated with the same release (and
which used to be called Whidbey a while back).

Longhorn is an operating system and should be released sometime during
2006, it doesn't have much to do with .NET, VS.NET or C# releases. Indigo
is a technology that was developed as part of Longhorn, even if it might
get ported back to XP. And Yukon is (or was?) the code name for the
upcoming release of SQL Server 2005.

Now, to get some confusion back - big talk right now is actually C# 3, not
2, and associated bits, because these were recently introduced to the
general public. The release of this _might_ coincide somehow with
Longhorn... ;-)


Oliver Sturm
 
Dave said:
Ah, that's interesting. Pardon my ignorance, but what is C# 2?

I have VS.NET 2003 (aka VS7.0) and .NET 1.1.

Not quite - VS.NET 2003 is VS7.1.
I know that VS is now at 2005
(beta) and that .NET will shortly be at 2.0, codenamed "Longhorn", or is it
"Whidbey", no, hang on "Indigo", or was it "Yukon" - oh boy, you can see I'm
getting confused.

Clarification would be greatly appreciated.

Okay. C# 2.0 is coming out with .NET 2.0 on November 7th, as part of VS
2005 (Whidbey). At the same time, SQL Server 2005 (Yukon) will be
released.

Entirely separately, there's Vista/Longhorn, the new OS, which will
hopefully ship in 2006. Vista will have extra components in, currently
called "WinFX". It's currently unclear to me whether this constitutes
..NET 3.0 or not. Some of these components (WPF, previously known as
Avalon, WCF previously known as Indigo, and WWF) are being
"backported" to some earlier operating systems. I would imagine they'll
ship at around the same time as Vista, but I don't know for sure.
 
Thanks Oliver, that's starting to make sense.
That's .NET 2.0 presumably.

My concern is this - I think I am correct that all XP SP2 installations have
..NET1.1 on them. However, if I wrote an application using VS2005 & .NET2.0
presumably it wouldn't necessarily run on .NET1.1.

Actually this leads me on to a bigger but related question (maybe I should
start a new thread): I am currently developing a C# .NET app (my first!). Is
it possible to include the .NET installation as part of the application
installation package so that users who don't have .NET (W98, XPSP1) or who
have an earlier version will be automatically upgraded? That would then solve
the above problem too.
 
Dave said:
My concern is this - I think I am correct that all XP SP2 installations have
.NET1.1 on them.

No, not necessarily.
However, if I wrote an application using VS2005 & .NET2.0
presumably it wouldn't necessarily run on .NET1.1.
Indeed.

Actually this leads me on to a bigger but related question (maybe I
should start a new thread): I am currently developing a C# .NET app
(my first!). Is it possible to include the .NET installation as part
of the application installation package so that users who don't have
.NET (W98, XPSP1) or who have an earlier version will be
automatically upgraded? That would then solve the above problem too.

You can certainly include the runtime redistributable and automatically
install it - I believe the installation projects make it pretty easy to
do so, in fact. Of course, you end up with a larger install package -
you might want to provide two versions, one for people who are sure
they've got the right version of .NET already, and one which includes
the installer. If people won't be downloading your product off the net
though - or if your app is so large that an extra 20MB (or however
much) won't make much impact, it would be safer to always have it
available :)
 
Who was it said "there are more questions than answers". Actually that's
great, but it's given me three more concepts to get my head round. - I've got
WPF (Windows Presentation Foundation - replaces Forms) and WCF (Windows
Communication Foundation, replaces remoting - I've just spent a good deal of
time and money on books learning remoting, I hope it wasn't wasted). But
what's WWF?

And why does Vista/Longhorn have TWO names??? (Don't bother, I don't care<G>)
 
Dave said:
Who was it said "there are more questions than answers". Actually that's
great, but it's given me three more concepts to get my head round. - I've got
WPF (Windows Presentation Foundation - replaces Forms)

Well, Windows Forms will still exist.
and WCF (Windows Communication Foundation, replaces remoting - I've
just spent a good deal of time and money on books learning remoting,
I hope it wasn't wasted).

Again, I don't think remoting is going to be removed, but WCF is
probably the preferred way to go.
But what's WWF?

Windows Workflow Foundation. See
http://msdn.microsoft.com/windowsvista/building/workflow/
And why does Vista/Longhorn have TWO names??? (Don't bother, I don't care<G>)

Longhorn was just the codename, just as Avalon was the codename for
WPF, etc.
 
Chris Dunaway said:
And here all this time I thought WWF = World Wrestling Federation!!

Nope...they got a Cease and Desist thingy from the World Wildlife Fund (WWF)
and now they are the WWE = World Wrestling Entertainment.

So when will Microsoft get a Cease and Desist thingy??? :^)

Bill
 
Bill Butler said:
Nope...they got a Cease and Desist thingy from the World Wildlife Fund (WWF)
and now they are the WWE = World Wrestling Entertainment.

So when will Microsoft get a Cease and Desist thingy??? :^)

.... or when will the World Wildlife Fund? :)
 
Bill Butler said:
Nope...they got a Cease and Desist thingy from the World Wildlife Fund (WWF)
and now they are the WWE = World Wrestling Entertainment.

So when will Microsoft get a Cease and Desist thingy??? :^)

If they're lawyer is smart he'll wait until after vista has shipped and
deamnd a 'licensing fee' that would cost MS less than recalling all the
existing retail packages.
 
Jon Skeet said:
... or when will the World Wildlife Fund? :)

Perhaps Microsoft will just buy them to avoid the issue. Then they can sue
Apple for using wildlife names in operating systems (Mac OS X Tiger).

SP
 
Back
Top