Microsoft
Software
Hardware
Network
Question : how can I override the DateTime class to add a custom method??
Hi, I want to override the default class System.DateTime to add a custom method, now i'm doing it this way (but doesn't works):
partial class DateTime
{
public string ToStringFormated()
{
return base.ToString(AppConfig.da
teFormat);
}
}
i''m getting a incoherence accessibility error.
Answer : how can I override the DateTime class to add a custom method??
DateTime is a class, you cannot derive a new class to override it.
The unique way is to use an extension method, but you require C# 3.0 for this (VS 2008), but still can use .net 2.0
Is that your case?
Random Solutions
Arrays in Excel macro
When establishing an ADO connection to a database, is it necessary to have a file path that is free of blank spaces?
Can't Crawl SharePoint Sites
Outlook XP won't install MAPI services
Error message saying cannot connect to linked SQL Server
MSSQL Service will not start up (Logs Posted)
Exchange 2003 Likely Corruption help
Access 2003 - How to create a timeline report
closing form without saving
Email report in PDF gives error