473,403 Members | 2,323 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,403 software developers and data experts.

Can I write as follow?

ABC
interface IWebPage
{
class SessionStructure {};
void SaveSession();
void LoadSession();
}

public class BasePage : IWebPage
{
class SessionStructure
{
int a;
int b;
}

void SaveSession() { ............. };
void LoadSession() { ............. };
}
Jan 12 '06 #1
8 1032
Well, there are a few problems here.

The first is that you should make the Save and LoadSession methods on
the BasePage class virtual, so that they can be overridden by derived
classes.

However, you can not extend the SessionStructure class like that. You
would have to create a new type.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"ABC" <ab*@abc.com> wrote in message
news:Oh**************@TK2MSFTNGP10.phx.gbl...
interface IWebPage
{
class SessionStructure {};
void SaveSession();
void LoadSession();
}

public class BasePage : IWebPage
{
class SessionStructure
{
int a;
int b;
}

void SaveSession() { ............. };
void LoadSession() { ............. };
}

Jan 12 '06 #2
KJ
No. As the compiler will tell you, interfaces cannot declare types.
Perhaps you might share why you want to do this, so alternatives may be
offered.

Jan 12 '06 #3
ABC
What alternatives can do similar case?
"KJ" <n_**********@mail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
No. As the compiler will tell you, interfaces cannot declare types.
Perhaps you might share why you want to do this, so alternatives may be
offered.

Jan 12 '06 #4
ABC <ab*@abc.com> wrote:
What alternatives can do similar case?


We need to know what you're actually trying to do before we can answer
that. It's not at all obvious how you expected to be able to use that
interface.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 12 '06 #5
"ABC" <ab*@abc.com> wrote in message
news:Ob*************@TK2MSFTNGP11.phx.gbl...
What alternatives can do similar case?


What are you actually trying to do...?
Jan 12 '06 #6
ABC
as each webpage has difference session structure to hold data, but each
webpage have similar behaviors to load and save session data to sessions
pool. I want to standardize the programmers coding, so the interface should
have a base session class and programmers should do some codes to add
properties to session structures, all programmers must use same session
structure name. I don't like they have own programming styles.

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
ABC <ab*@abc.com> wrote:
What alternatives can do similar case?


We need to know what you're actually trying to do before we can answer
that. It's not at all obvious how you expected to be able to use that
interface.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Jan 12 '06 #7
ABC <ab*@abc.com> wrote:
as each webpage has difference session structure to hold data, but each
webpage have similar behaviors to load and save session data to sessions
pool. I want to standardize the programmers coding, so the interface should
have a base session class and programmers should do some codes to add
properties to session structures, all programmers must use same session
structure name. I don't like they have own programming styles.


No, you can't enforce naming like this. (Nor would the interface be
expressing anything you could actually *use* given only a reference to
an instance of the interface.) I can't see how it's agood idea though
anyway - it would make things very awkward if you had two web pages
which actually needed the same session structure. They'd have to
declare the same thing twice, which is bad practice.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 12 '06 #8
KJ
Have you considered using inheritance, or a combination of inheritance
and delegation?

Jan 12 '06 #9

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

Similar topics

33
by: Xah Lee | last post by:
i've started to read python tutorial recently. http://python.org/doc/2.3.4/tut/tut.html Here are some quick critique: quick example: If the input string is too long, they don't truncate it,...
1
by: Vincy | last post by:
Hi, I have the follow problem: a windows is divided on two frames: frame1 and frame2. on frame 2 there is a buttom it runs a function 'SendMsg' that write (by operator 'write' of javascript) a...
13
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
6
by: ok | last post by:
<img src="http://www.6park.com/enter2/av.gif" onload="document.write('an iframe obj');"> First of all, it destroy the HTML page. Secondly even if it does not destroy it, the iframe object will...
40
by: Neo The One | last post by:
I think C# is forcing us to write more code by enforcing a rule that can be summarized as 'A local variable must be assgined *explicitly* before reading its value.' If you are interested in what...
0
by: Ravikanth[MVP] | last post by:
Hi Use the following code. string sJoblogFileName = "TextFile.txt"; System.IO.StreamWriter LogFile =new System.IO.StreamWriter (sJoblogFileName,true); LogFile.WriteLine("blah blah blah");...
4
by: Seok Bee | last post by:
Dear Experts, I have created a script to extract the Event Logs from the system into an excel sheet. The logs are separated into 2 worksheets (Application Log and System Log). After this excel...
1
by: leopl | last post by:
Dear all I have written a write statement as follow:- write #1 me.textmessage the output came out to be as follow:- "(contents of the me.textmessage)"
0
by: Med | last post by:
Hi, From http://dotnetguts.blogspot.com/2008/07/url-rewriting-with-urlrewriternet.html I managed to rewrite http://www.example.com/product.aspx?productname=Panasonic+TV to:...
2
by: jeddiki | last post by:
Hello, I want to create my own index of websites based on my criteria rather than big G's. For example, I might like to index websites according to what they have in their "author" Meta tag (...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
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...

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.