|
Hi,
this is how I understand it:
- you can create a special list of Days, with class SpecialDays1 : Days, but then the items have type Day
- you can create a list of SpecialDays, with class SpecialDays2 : List(SpecialDays), but then you don't inherit from Days.
However if you want a special list of special days, then you should inherit from a generic special list. You could achieve that like so (you may want to restrict T below):
public class DayList< T> : List< T> {}
public class SpecialDayList< T> : DayList< T> { ... }
public class Day { }
public class SpecialDay : Day { ... }
public class Days : DayList< Day> { }
public class SpecialListOfSpecialDays : SpecialDayList< SpecialDay>
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, February 27, 2009 9:04 AM
|
|
|
|
|
Yeah, that sounds about right. Maybe add where clauses to the lists.
|
|
|
|
|
If you're asking about multiple inheritance, that is, a class SpecialistDays that inherits from both SpecialistDay and Days, then, unfortunately, you can't do that in .NET. This could also lead to the Fragile Base Class[^] problem if your base classes change a lot; this problem lead to the famous article Why extends is evil[^], a Java-based discussion that is completely applicable to the C# world.
Perhaps you want to do the following:
public interface IDay {...}
public interface IDays {...}
public interface ISpecialistDay : IDay {...}
public interface ISpecialistDays : IDays {...}
public Day : IDay {...}
public Days : IDays {...}
public SpecialistDay : ISpecialistDay
{
... ISpecialistDay methods here ...
... method proxies for IDay methods to internal Day ...
private Day _internalDay;
}
public SpecialistDays : ISpecialistDays
{
... ISpecialistDays methods here ...
... method proxies for ISpecialistDay methods to internal Days ...
private Days _internalDays;
} This way you get the inheritance of the methods without worrying about implementation.
You don't see a lot of this in C#/VB.NET because creating partial proxy objects often feels painful. Alas, it's what we've got.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hello, i use this to transform an excel file to pdf :
<br />
static void Main(string[] args)<br />
{<br />
ApplicationClass excelApplication = new ApplicationClass();<br />
Workbook excelWorkBook = null;<br />
<br />
<br />
<br />
string paramSourceBookPath = @"C:\2.xlsx";<br />
object paramMissing = Type.Missing;<br />
<br />
string paramExportFilePath = @"C:\test.pdf";<br />
XlFixedFormatType paramExportFormat = XlFixedFormatType.xlTypePDF;<br />
XlFixedFormatQuality paramExportQuality =<br />
XlFixedFormatQuality.xlQualityStandard;<br />
bool paramOpenAfterPublish = false;<br />
bool paramIncludeDocProps = true;<br />
bool paramIgnorePrintAreas = true;<br />
object paramFromPage = Type.Missing;<br />
object paramToPage = Type.Missing;<br />
<br />
<br />
<br />
try<br />
{<br />
excelWorkBook = excelApplication.Workbooks.Open(paramSourceBookPath,<br />
paramMissing, paramMissing, paramMissing, paramMissing,<br />
paramMissing, paramMissing, paramMissing, paramMissing,<br />
paramMissing, paramMissing, paramMissing, paramMissing,<br />
paramMissing, paramMissing);<br />
<br />
if (excelWorkBook != null)<br />
excelWorkBook.ExportAsFixedFormat(paramExportFormat,<br />
paramExportFilePath, paramExportQuality,<br />
paramIncludeDocProps, paramIgnorePrintAreas, paramFromPage,<br />
paramToPage, paramOpenAfterPublish,<br />
paramMissing);<br />
}<br />
catch (Exception ex)<br />
{<br />
Console.WriteLine(ex.ToString());<br />
}<br />
finally<br />
{<br />
if (excelWorkBook != null)<br />
{<br />
excelWorkBook.Close(false, paramMissing, paramMissing);<br />
excelWorkBook = null;<br />
}<br />
<br />
if (excelApplication != null)<br />
{<br />
excelApplication.Quit();<br />
excelApplication = null;<br />
}<br />
<br />
GC.Collect();<br />
GC.WaitForPendingFinalizers();<br />
GC.Collect();<br />
GC.WaitForPendingFinalizers();<br />
}<br />
<br />
<br />
}<br />
But how i can set the file in A4 format? because my excel file is bigger than A4, thank you verry mutch.
|
|
|
|
|
Hi All,
I have opened one bmp file and I want to save this bitmap as monochrom bitmap file. Please do note when the monochrom file is open using mspaint or any other tool and when you select save as it should automatically give monochrom bitmap format.
Can anybody help me out here.
|
|
|
|
|
|
hi,
i am making use of FolderBrowserDialog of .net. the problem is it is showing me control panel when FolderBrowserDialog under my computer and it allows files to be saved in administrator tool. how to avoid showing control panel.
|
|
|
|
|
You cannot customize FolderBrowserDialog , to hide special folders. If its visible in Windows Explorer, then its visible on your dialog too.
To hide "Control Panel" from Win Explorer, go to "Folder Options", "View" tab, and uncheck "Show Control Panel in My Computer".
Calin
|
|
|
|
|
Calin,
the Control Panel is hidden in win explorer i,e the check box is unchecked, but still the FolderBrowserDialog is showing the control panel.
|
|
|
|
|
|
yes i think i need to build my own custom control for this... thanks for the input...
regards
sudhir
|
|
|
|
|
Even if you hide the Control Panel, user can always manually travel to the folder location and save files there. Hence, hiding control panel is not going to solve your problem.
All I can suggest is to create your own control and do not let user select the folder you dont want to.
Time is the best teacher; unfortunately it kills all of its students.
जय हिंद
|
|
|
|
|
yes i think i need to build my own custom control for this
regards,
sudhir
|
|
|
|
|
what about error handling after the dialog is confirmed?
you can check the directory, if its one you dont what to use then inform the user and display the folderbrowsedialog again
If only MySelf.Visible was more than just a getter...
A person can produce over 5 times there own body weight in excrement each year... please re-read your questions before posting
|
|
|
|
|
yes now i am doing that only as i want to avoid user saving the files in administrator tools folder, i am checking is he selected theat folder and if yes then i am showing him a msg telling he cant save there...
thanks anyway...
|
|
|
|
|
Hi,
How can word document pages convert to jpeg?
Thankyou
Yesuprakash
|
|
|
|
|
It is not easy.
One idea would be:
-open the document, using Microsoft.Office.Interop.Word .
-select the active document, word.ActiveDocument.Select()
-copy current selection, word.Selection.CopyAsPicture()
-get the Image by calling Clipboard.GetImage()
Calin
|
|
|
|
|
With opening the word file i want to get the images of all pages.Is it possible
Thankyou,
Yesuprakash
|
|
|
|
|
Document.Select() selects the entire document, so basically, you will copy the entire document.
Calin
|
|
|
|
|
Hi I am writing a small program , I need to find the application data folder which exists in c:\documents and settings folder. I need to know the exact path, if the user has installed the windows in d:\ then it should look at d:\. Even if I could know the windows installation drive then I think it would help ? I got some code in VB but i cannot use it in csharp . Any suggestions would be appreciated.
//************************************************************
Public Function GetTheWindowsDirectory() As String
Dim strWindowsDir As String ' Variable to return the path of Windows Directory
Dim lngWindowsDirLength As Long ' Variable to return the the lenght of the path
strWindowsDir = Space(250) ' Initilize the buffer to receive the string
lngWindowsDirLength = GetWindowsDirectory(strWindowsDir, 250) ' Read the path of 'the windows directory
strWindowsDir = Left(strWindowsDir, lngWindowsDirLength) ' Extract the windows 'path from the buffer
GetTheWindowsDirectory = strWindowsDir
//*********************************************
The above is the code for vb.net
Thanks
|
|
|
|
|
Hi,
The Environment class in the System namespace contains methods to get all of this info.
The GetFolderPath method is especially useful.
Alan
|
|
|
|
|
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
|
|
|
|
The APPDATA environment variable.
string filename = System.Environment.ExpandEnvironmentVariables ( "%APPDATA%\\myfile.txt" ) ;
(If I recall correctly.)
|
|
|
|
|
Hi friend
I am having a problem with passing a button and form to a method.
Let me explain detail.when i click a button it will send some this button and a form to a method. The method then do some job. like
private void btnEducationNFinance_Click(object sender, EventArgs e)
{
showForm(button1, i , formName); //Any Wrong ?
}
public void ShowForm(.......) // I need this declearation
{
form1 frm = new formName);
frm.show();
}
Thanks
|
|
|
|
|
hmmm... if your hardcoding the function call why dont you just create an instance of the form you want to show?
When would a button click open different forms?
If only MySelf.Visible was more than just a getter...
A person can produce over 5 times there own body weight in excrement each year... please re-read your questions before posting
|
|
|
|