|
i have the following problem:
1. i have an interface with few methods which i cannot change.
2. i am creating a base class that realizes the methods which are defined
in that interface (but this class doesn't inherit from the interface).
This class will be called the "Base" class.
3. i have 2 other classes which inherits from both the interface and the base class. (will be
referenced as Classes A and B)
what i need is this:
the base class should hold all the similar functionalities (methods) for both A and B which are also defined in the interface. i want to remove all these methods from A and B.
it doesn't compile with an error that says i am not realizing the interface's methods inside A and B (but they ARE realized in the base class which A and B are inheriting from).
is there a way to make this work?
Thanks.
|
|
|
|
|
Simple: implement the interface on Base and mark the methods that need to be different on the derived classes as "virtual" or "abstract". Then, override as needed.
Yes, even I am blogging now!
|
|
|
|
|
|
<br />
using System;<br />
namespace ConsoleApp<br />
{<br />
public interface IMe<br />
{<br />
void Disp();<br />
}<br />
abstract class BaseCls<br />
{<br />
public virtual void Display()<br />
{<br />
<br />
}<br />
}<br />
class B:BaseCls,IMe<br />
{<br />
public void Disp()<br />
{<br />
Console.WriteLine("i am from interface");<br />
}<br />
public override void Display()<br />
{<br />
this.Disp();<br />
}<br />
}<br />
class Implimet<br />
{<br />
static void Main()<br />
{<br />
B Bobj=new B();<br />
Bobj.Disp();<br />
Bobj.Display();<br />
}<br />
}<br />
}<br />
<br />
Sreejith Nair
[ My Articles ]
|
|
|
|
|
I am currently working on UPNP technology with c#.
http://www.intel.com/technology/upnp/. Anyone interested in a chat on how to develop upnp devices using C#.Sample source code sharing and innovative ideas will help all developers work with the technology of the future.
Kill The Tester
|
|
|
|
|
|
"RasGetProjectionInfo" function in MSDN.
this is right?
[DllImport("Rasapi32.dll", CharSet = CharSet.Auto)]
public static extern uint RasGetProjectionInfo(IntPtr hrasconn,RASPROJECTION rasprojection,[Out]RASPPPIP[] test,ref int size);
public struct RASPPPIP
{
[MarshalAs(UnmanagedType.U4,SizeConst=4)]
public uint dwSize;
[MarshalAs(UnmanagedType.ByValArray,SizeConst=44)]
public byte[] bt;
}
public enum RASPROJECTION
{
RASP_Amb = 0x10000,
RASP_PppNbf = 0x803F,
RASP_PppIpx = 0x802B,
RASP_PppIp = 0x8021,
RASP_PppCcp = 0x80FD,
RASP_PppLcp = 0xC021,
RASP_Slip = 0x20000
}
when i call this function in C#,it's return 632 or 87...
int ii = 0;
RASPPPIP[] rasPPPIP = new rasPPPIP[1];
rasPPPIP[0].dwSize = (uint)Marshal.SizeOf(typeof(RASPPPIP));
RasFunction.RasGetProjectionInfo(connectedRasHandle,RASPROJECTION.RASP_PppIp,rasPPPIP,ref ii);
"connectedRasHandle" is correct,and i can call RasHangUp(connectedRasHandle)
I'm going crazy ...
Help !
|
|
|
|
|
MSDN docs have it down in black and white. A non-zero return code means that you have a problem.
632 - ERROR_INVALID_SIZE - The dwSize member of the structure pointed to by lpprojection specifies an invalid size
87 - ERROR_INVALID_PARAMETER - One of the parameters is invalid
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
But , How can I do?
I call this function in VC++6.0 is correct!and the dwSize=48,In C# as same as VC++.
Help
|
|
|
|
|
I got it for you
Use this as the struct definition:
[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode)]
public struct RASPPPIP
{
public uint dwSize;
public uint dwError;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=16)]
public string szIpAddress;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=16)]
public string szServerIpAddress;
public uint dwOptions;
public uint dwServerOptions;
}
Call like this:
RASPPPIP info = new RASPPPIP();
info.dwSize = 72;
int size = 72;
RasGetProjectionInfo(r.hrasconn, RASPROJECTION.RASP_PppIp, ref info, ref size);
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Hello all, when I tried the solution as it was posted it did not work for me I am trying to call RasGetProjectionInfo by Pinvoking the rasapi32.dll on WinXP. I have no problem connecting to my RAS server but When I pass it back the appropriate params and structures I get back empty strings for szIpAddress and szServerIpAddress or if I modify my code to CharSet=CharSet.Unicode I get nulls.. ( listed below is the code )
Any help would be appreciated.., Thanks
[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Auto)]
public class RASPPPIP
{
public uint dwSize = 72;
public uint dwError;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=16)]
public string szIpAddress;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=16)]
public string szServerIpAddress;
}
public enum RASPROJECTION:uint
{
RASP_AMB = 0x10000,
RASP_PppNbf = 0x803F,
RASP_PppIpx = 0x802B,
RASP_PppIp = 0x8021,
RASP_PppCcp = 0x80FD,
RASP_PppLcp = 0xC021,
RASP_Slip = 0x20000
}
[DllImport("rasapi32.dll",CharSet=CharSet.Auto)]
public extern static uint RasGetProjectionInfo(
IntPtr hRasConn,
RASPROJECTION projection,
[In,Out] RASPPPIP pppip,
ref uint ppipSize
);
and the calling function ...
public void Dial()
{
if(_Handle!=IntPtr.Zero)
{
RASCONNSTATUS status=new RASCONNSTATUS();
uint res=Ras.RasGetConnectStatus(_Handle,status);
if(res==6) //res=ERROR_INVALID_HANDLE
_Handle=IntPtr.Zero;
else
return;
}
try
{
Ras.RasCheck(Ras.RasDial(null,_Phonebook,_Params,1,_DialNotifyDelegate,ref _Handle));
Ras.RasConnectionNotification(_Handle,this._DisconnEvent.Handle,RASNOTIFICATION.RASCN_Disconnection);
RASPPPIP pppip = new RASPPPIP();
uint size = pppip.dwSize;
uint ipstatus = 0;
ipstatus = Ras.RasGetProjectionInfo(this._Handle,RASPROJECTION.RASP_PppIp,pppip,ref size);
StartWatch();
}
catch(RasException e)
{
OnError(e.ErrorCode,e.Message);
}
}
|
|
|
|
|
I got it to work by making the following changes to my original code.
[StructLayout (LayoutKind.Sequential,CharSet=CharSet.Auto)]
[MarshalAs (UnmanagedType.ByValStr,SizeConst=(int)16)]
public string szIpAddress;
[MarshalAs (UnmanagedType.ByValStr,SizeConst=(int)16)]
public string szServerIpAddress;
// In the calling function
ipstatus = Ras.RasGetProjection(this._Handle,RASPROJECTION.RASP_PppIp,pppip,ref size);
|
|
|
|
|
hey people,
I need some idea on creating a web part on sharepoint.
I need a web part that could add user both on Active Directory and on the SharePoint site, all at the same page. This is to remove the hassle of creating separate users (on separate processes, of course) on my Active Directory Service and on Windows SharePoint Services.
Any suggestions would really be helpful, or if somebody already has it, please tell me
Thanks and good day
|
|
|
|
|
How to get the 'columnname' of a chosen cell in a grid...my grid's columnnames are the dates and i want to get that specific date whenever i clicked on a certain cell...i need this badly...please help me...thanks!
|
|
|
|
|
Very simple problem. You should have googled first. Here is a wonderful link for the DataGrid: www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp[^]
Please delete the other thread you started if you have a double post.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Hi
have a look here.it should be something what you look for
www.codeproject.com/cs/database/DatabaseAcessWithAdoNet1.asp#xx953344xx
Huseyin
|
|
|
|
|
How to get the 'columnname' of a chosen cell in a grid...my grid's columnnames are the dates and i want to get that specific date whenever i clicked on a certain cell...i need this badly...please help me...thanks!
|
|
|
|
|
I am developing an MDI vector drawing appliction and have, after trying to implement a auto-scroll bar, found that it now draws in the main MDI container. How can I limit the drawing to the active child form?
Andy
|
|
|
|
|
Hi,
Please tell me whether all dates except all mondays can be disabled in Date Time Picker control or not. If yes then how?
Thanks in Advance.
Manoj
|
|
|
|
|
No simple way of doing this unless you subclasses the control. Even then I haven't looked into it but I know that its going to be messy.
You can try to solve your problem by validating the input and ignoring the dates that you want to throw out. If that doesn't work it will be much easier to find an alternative control.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
hi, i've got this window form. i need to pass this value string d into another class to do some dbconnection..
<br />
public class Form1 : System.Windows.Forms.Form<br />
{<br />
<br />
public string d = "20"; <br />
.<br />
.<br />
.<br />
.<br />
<br />
private void testing()<br />
{<br />
<br />
dbConnection dbcon = new dbConnection();<br />
dbcon.Connection()<br />
<br />
}<br />
}
<br />
public class dbConnection <br />
{<br />
public OleDbConnection conn;<br />
public string SQL ; <br />
public OleDbCommand cmd;<br />
public OleDbDataAdapter adpt; <br />
public DataSet ds; <br />
<br />
public dbConnection()<br />
{<br />
<br />
conn = new System.Data.OleDb.OleDbConnection();<br />
conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +<br />
"Data source = "+Application.StartupPath +@"\db.mdb";<br />
<br />
}<br />
<br />
public void Connection()<br />
{<br />
<br />
Form1 ccF = new Form1();<br />
<br />
SQL = "SELECT * FROM Table WHERE ID <='" + (ccF.d) + "'"; <br />
cmd = new System.Data.OleDb.OleDbCommand (SQL, conn);<br />
adpt = new System.Data.OleDb.OleDbDataAdapter(cmd); <br />
ds = new System.Data.DataSet(); <br />
adpt.Fill(ds,"Table ");<br />
<br />
}<br />
<br />
}
my problem is that it can't read ccF.d.. sorry im kinda bad in using class..
Chris
|
|
|
|
|
What do you mean exactly by "read ccF"? What do you want to read and where?
www.troschuetz.de
|
|
|
|
|
First check that u have called ur testing function at some point in ur Form1.
Second I tried ur code and it works for me as far as reading ccF.d is concerned.
So i guess there is come problem in the way ur accessing it.
My working code of Form 1 is as under
public class Form1 : System.Windows.Forms.Form
{
public string d = "HI";
private void Form1_Load(object sender, System.EventArgs e)
{
testing();
}
private void testing()
{
dbConnection dbcon = new dbConnection();
MessageBox.Show(dbcon.Connection());
}
}
public class dbConnection
{
public string SQl;
public string Connection()
{
Form1 ccF = new Form1();
return SQl = ccF.d;
}
}
Ketty
|
|
|
|
|
How can i send my new exe file to other client machine's from the
Server.(without go and copy individualy).
I would like to develop a application in c#.can any one help me to start
this application.
Thanks
Amal
|
|
|
|
|
Assuming that you own all the client computers, and assuming that your computers are >= windows 2k (less problems)...
- Create an MSI install package.
- Use Group Policies to deploy the package.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|