|
|
Also wrong, you can have constructors on abstract classes, inheriting classes can access them. It's not the best practice, because then all inheriting class must have a constructor with matching signature, but you can do it.
public abstract class BaseClass {
protected string name;
public BaseClass(string name) {
this.name = name;
}
}
public class ChildClass : BaseClass {
public ChildClass(string name) : base(name) {
}
}
And you can instantiate your inherited type with an abstract instance, that's what polymorphism is all about. You can't construct an abstract class, but you can construct concrete implementations of it as if they were the abstract class. Meaning you can use any class that inherits from the base class as an instance of the base class.
public abstract class Setting {
}
public class SimpleSetting : Setting {
private Setting parent;
public SimpleSetting() {
}
public SimpleSetting(Setting parent) {
this.parent = parent;
}
}
public class CollectionSetting : Setting {
private Setting parent;
public CollectionSetting(Setting parent) {
this.parent = parent;
}
}
public class Test {
static void Main(string[] args) {
Setting s = new CollectionSetting(new SimpleSetting());
}
}
But you are right about abstract members, don't know where they heard you can only have static members on abstract types. You can do everything with a abstract type that you can with a normal class.
Visit BoneSoft.com
|
|
|
|
|
|
It's usually a can of worms you don't wanna open, but it can be done. Unless for some strange reason you want to insure that all inheritors have a specific constructor, which is somewhat unorthodox to dictate from a base class. Once upon a time, I read something that listed another reason or two why not to do that, but I don't remember what they said. It's probably wise to continue believing that it can't be done.
Visit BoneSoft.com
|
|
|
|
|
You would want a constructor in an abstract class if you want to establish rules of required constructor parameters fed to the ABC.
|
|
|
|
|
How to get the day of the given date in c#.net. Is it possible to add 30 days from the given date which omits the saturdays and sundays? Help me.
SR Ranjini
|
|
|
|
|
try out following codes
DateTime drt = new DateTime(2004,04,21);
MessageBox.Show(drt.DayOfWeek.ToString());
rahul
|
|
|
|
|
Hi,
U right the code below,
.......(Put the TextBox in the Web Form)
TextBox1.Text = DateTime.now; // For the current Date & Time //
I don't know how to omit sat. & sun days from the month.
Regards,
Jesal Rana
OK
|
|
|
|
|
Hello Folks,
I really need help to solve a real stupid situation
I have a SQL Server database table named MAINT_START.Columns of this table are:
PlateNumber char(11)--------> PK
MaintEntryDate smalldatetime---> PK
MaintReason char(20)
I want to update this table's MaintReason column via a SQL String. My code is like this:
/**********************************************************************
string strUpdate="UPDATE MAINT_START SET MaintReason='" + cMaintReason.Text.TrimEnd() + "'," +
" MaintCompany='" + cMaintCompany.Text.TrimEnd() + "'," +
" MaintCompanyTel='" + cMaintCompanyTel.Text.TrimEnd() + "'," +
" MaintCompanyAddress='" + cMaintCompanyAddress.Text.TrimEnd() + "'" +
" WHERE PlateNumber='" + cPlateNumber.Text + "' AND" +
" MaintEntryDate =Convert.ToDateTime(cMaintEntry.Text)";
SqlCommand aCommand=new SqlCommand(strUpdate,Myconnection);
/************************************************************************
Dear friends is it really impossible to insert or update a smalldatetime column?
Please Help..
|
|
|
|
|
|
Firstly I would like to say thank you for you attention. I already tried to get success result via a stored procedure. And unfortunately the result was not ok.Here is my stored procedure:
/****************************************************************
CREATE PROCEDURE [MaintStartUpdate]
(@PlateNumber_1 [char],
@MaintEntryDate_2 [smalldatetime],
@MaintReason_5 [char](20),
@MaintCompany_6 [char](20),
@MaintCompanyTel_7 [char](11),
@MaintCompanyAddress_8 [nvarchar](50))
AS
UPDATE [CollLogistics].[dbo].[MAINT_START]
SET
[MaintReason] = @MaintReason_5,
[MaintCompany] = @MaintCompany_6,
[MaintCompanyTel] = @MaintCompanyTel_7,
[MaintCompanyAddress] = @MaintCompanyAddress_8
WHERE
PlateNumber = @PlateNumber_1 AND
[MaintEntryDate]= @MaintEntryDate_2
GO
/**************************************************************
I really want to crash my computer right now. Because this is a very stupid and easy SQL update...And I still could not do anything!
|
|
|
|
|
|
I am really sorry for my bad english..
The question is I think very simple? How can I send a smalldate parameter from c# to SQL server. That's all!
|
|
|
|
|
|
I'm not really that experienced in SQL, but...
We all know that queries are only text, so if you want to pass a date to SQL server, you should pass it as a text. And why not? I believe it would be something like:
string strUpdate="UPDATE MAINT_START SET MaintReason='" + cMaintReason.Text.TrimEnd() + "'," +
" MaintCompany='" + cMaintCompany.Text.TrimEnd() + "'," +
" MaintCompanyTel='" + cMaintCompanyTel.Text.TrimEnd() + "'," +
" MaintCompanyAddress='" + cMaintCompanyAddress.Text.TrimEnd() + "'" +
" WHERE PlateNumber='" + cPlateNumber.Text + "' AND" +
" MaintEntryDate =" DateTime.Parse(cMaintEntry.Text).ToString();
Did you notice the Parse-ToString way?
Another way if you really want to pass it as a datetime -I really can't see why the persistence - perhaps you should consider using Typed datasets rather than SQLCommands?? Just a suggestion.
I hope that was close enough;)
|
|
|
|
|
|
I am unable apply visual themes and effects in my application. which file i should use to inherit the class and its members to my application to use its effects.
Crack the core
|
|
|
|
|
I'm assuming you're talking about Windows XP themes...
There are a couple of things you have to do (with 2003 projects anyway, with 2005 I don't know that it's necessary) to show XP themes.
You have to set the FlatStyle property of all UI components that have the property to System:
this.checkBox1.FlatStyle = System.Windows.Forms.FlatStyle.System;
And you need to include a manifest file named "YOUR_EXE.exe.manifest" in the project like the following:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="YOUR_EXE"
type="win32"
/>
<description>.NET control deployment tool</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
Where YOUR_EXE is the name of your exe. It's been a while, but I think that's all you have to do. Good luck.
Visit BoneSoft.com
|
|
|
|
|
hi all,
> how can i transfer a textbox.text with a dll from winapp1 to winapp2 ?
> the two applications do different jobs. but they have some textboxes in common.
so i just want the user to fill the winapp2.
when he/she clicks on save button, i want to transfer same values with a dll to the winapp1 and that dll should call save button event on winapp1 in it as well.
is this possible ?
if yes, how can i achieve this ?
help please,
thanks in advance,
bye.
|
|
|
|
|
Use an interface dll. Both projects will reference the interface and implement it as well.
|
|
|
|
|
i am using sql server along with C#
i want to use both string and integer values in one query and i am writing this query below
return "Insert INTO "+tableName+" (id,name,client,expstartdate,expenddate,cost,description)Values('+createpro.propertyPId+','"+createpro.propertyPname+"','"+createpro.propertyClient+"','"+createpro.propertyExpStDate+"','"+createpro.propertyExpEndDate+"','+createpro.propertycost+','"+createpro.propertydescription"')";
but this query giving an error,
is this query is right for the solution of my problem; if not then give me the solution
muhammad mahmood ilyas
|
|
|
|
|
put your query string in a local variable and display it. you will see that there are missing quotes. it looks like you mixed quote and apostrophe up.
try this (untested; im not sure about the date format):
"Insert INTO " + tableName + " (
id,
name,
client,
expstartdate,
expenddate,
cost,
description) Values( " +
createpro.propertyPId + ", " +
"'" + createpro.propertyPname + "', " +
createpro.propertyClient + ", " +
"'" + createpro.propertyExpStDate + "', " +
"'" + createpro.propertyExpEndDate+ "', " +
"'" + createpro.propertycost + "', " +
"'" + createpro.propertydescription + "'" +
")"
|
|
|
|
|
|
hi try this one:-
"Insert INTO "+tableName+" (id,name,client,expstartdate,expenddate,cost,description)Values('+createpro.propertyPId+',' "+createpro.propertyPname+" ',' "+createpro.propertyClient+" ',' "+createpro.propertyExpStDate+" ',' "+createpro.propertyExpEndDate+" ','+createpro.propertycost+',' "+createpro.propertydescription" ')";
|
|
|
|
|