tryston02
August 3rd, 2005, 09:29 AM
Hey guys,
I'm using C# 2.0 and thought I would take advantage of the new params keyword (I might not even need it if someone can show me another way).
I'm making a custom class that handles files that our customers upload via the upload control. I want to only allow certain types of files to be uploaded, and was going to leave this up to the consumer of this object to specify in the contructor what file types they would like to allow from a predifined list.
i.e. UploadFile_strict(msWord, msExcel) or just UploadFile_strict(msWord)
I want to allow:
msWord doc
msExcel doc
text file
csv file
I've made them private variables like so:
private string _msWord;
private string _msExcel;
private string _textFile;
private string _csvFile;
I thought about creating a constuctor like so:
public UploadFile_strict(params string[] strFileType)
{
//how would a for-each work here? How would it assign these values to the private variables?
}
Should I get rid of the private variables and make it an array? How would you guys acheive this?
Thanks for any help,
Chris
I'm using C# 2.0 and thought I would take advantage of the new params keyword (I might not even need it if someone can show me another way).
I'm making a custom class that handles files that our customers upload via the upload control. I want to only allow certain types of files to be uploaded, and was going to leave this up to the consumer of this object to specify in the contructor what file types they would like to allow from a predifined list.
i.e. UploadFile_strict(msWord, msExcel) or just UploadFile_strict(msWord)
I want to allow:
msWord doc
msExcel doc
text file
csv file
I've made them private variables like so:
private string _msWord;
private string _msExcel;
private string _textFile;
private string _csvFile;
I thought about creating a constuctor like so:
public UploadFile_strict(params string[] strFileType)
{
//how would a for-each work here? How would it assign these values to the private variables?
}
Should I get rid of the private variables and make it an array? How would you guys acheive this?
Thanks for any help,
Chris