473,574 Members | 3,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can I write as follow?

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

public class BasePage : IWebPage
{
class SessionStructur e
{
int a;
int b;
}

void SaveSession() { ............. };
void LoadSession() { ............. };
}
Jan 12 '06 #1
8 1038
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 SessionStructur e class like that. You
would have to create a new type.

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

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

public class BasePage : IWebPage
{
class SessionStructur e
{
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_**********@m ail.com> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.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.co m>
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******** *****@TK2MSFTNG P11.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.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
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.co m>
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.co m>
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
1887
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, but return it unchanged; this will mess up your column lay-out but that's usually better than the alternative, which would be lying about a value....
1
1127
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 string with link (this link should show a alert message) on frame1. follow the javascript code:
13
9602
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 assigned to a variable and output using document.write. (Note, there is no submit button or other form elements. Basically
6
12572
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 be within an img tag. How do I write a new iframe obj outside img tag?
40
3024
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 I mean, please look at this feedback my me: ...
0
2537
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"); LogFile.Close();
4
7274
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 file being created, it will be sent out via email to the list of recipients. I run the script on my notebook (also developed on th same machine) it...
1
1710
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
1014
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: http://www.example.com/Panasonic-TV-123.aspx I am new to URL re-write and I have couple of questions:
2
5137
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 ( and rejecting any site that doesn't have one). I will use this idea as a working example. Here is my suggested methodology and I would like some...
0
7842
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8110
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5658
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5336
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3775
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3794
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2277
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 we have to send another system
0
1102
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.