Click here to Skip to main content
15,905,232 members
Home / Discussions / C#
   

C#

 
GeneralRe: How do I transfer files over a local network? Pin
Keith Barrow22-Dec-10 10:38
professionalKeith Barrow22-Dec-10 10:38 
GeneralRe: How do I transfer files over a local network? Pin
fjdiewornncalwe22-Dec-10 10:41
professionalfjdiewornncalwe22-Dec-10 10:41 
GeneralRe: How do I transfer files over a local network? PinPopular
Pete O'Hanlon22-Dec-10 10:46
mvePete O'Hanlon22-Dec-10 10:46 
GeneralRe: How do I transfer files over a local network? PinPopular
Richard MacCutchan22-Dec-10 11:18
mveRichard MacCutchan22-Dec-10 11:18 
GeneralRe: How do I transfer files over a local network? Pin
dan!sh 22-Dec-10 20:24
professional dan!sh 22-Dec-10 20:24 
GeneralRe: How do I transfer files over a local network? Pin
Richard MacCutchan22-Dec-10 21:59
mveRichard MacCutchan22-Dec-10 21:59 
GeneralRe: How do I transfer files over a local network? Pin
_Erik_23-Dec-10 3:32
_Erik_23-Dec-10 3:32 
AnswerRe: How do I transfer files over a local network? Pin
jschell23-Dec-10 7:08
jschell23-Dec-10 7:08 
QuestionApproximation Taylor and Furie series with neuro network Pin
elinehsani22-Dec-10 0:12
elinehsani22-Dec-10 0:12 
AnswerRe: Approximation Taylor and Furie series with neuro network Pin
phil.o22-Dec-10 0:23
professionalphil.o22-Dec-10 0:23 
AnswerRe: Approximation Taylor and Furie series with neuro network Pin
Pete O'Hanlon22-Dec-10 0:25
mvePete O'Hanlon22-Dec-10 0:25 
GeneralRe: Approximation Taylor and Furie series with neuro network Pin
OriginalGriff22-Dec-10 0:45
mveOriginalGriff22-Dec-10 0:45 
GeneralRe: Approximation Taylor and Furie series with neuro network Pin
Pete O'Hanlon22-Dec-10 3:14
mvePete O'Hanlon22-Dec-10 3:14 
GeneralRe: Approximation Taylor and Furie series with neuro network Pin
musefan22-Dec-10 4:09
musefan22-Dec-10 4:09 
AnswerRe: Approximation Taylor and Furie series with neuro network Pin
Keith Barrow22-Dec-10 3:28
professionalKeith Barrow22-Dec-10 3:28 
AnswerRe: Approximation Taylor and Furie series with neuro network Pin
musefan22-Dec-10 4:15
musefan22-Dec-10 4:15 
AnswerRe: Approximation Taylor and Furie series with neuro network Pin
Alan Balkany22-Dec-10 4:28
Alan Balkany22-Dec-10 4:28 
Questiondatagridview checkbox problem [modified] Pin
Varun Sareen21-Dec-10 18:46
Varun Sareen21-Dec-10 18:46 
AnswerRe: datagridview checkbox problem Pin
Hiren solanki21-Dec-10 19:56
Hiren solanki21-Dec-10 19:56 
GeneralRe: datagridview checkbox problem [modified] Pin
Varun Sareen21-Dec-10 20:09
Varun Sareen21-Dec-10 20:09 
AnswerRe: datagridview checkbox problem Pin
GenJerDan22-Dec-10 11:25
GenJerDan22-Dec-10 11:25 
QuestionStyle vs Performance Pin
Roger Wright21-Dec-10 17:50
professionalRoger Wright21-Dec-10 17:50 
I've got a bit of code that works nicely, but it's really ugly and it offends my sense of style. To wit,

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            
        }
        private static string Header = @"^(D|""D|T|S|I|E|""Z)";
        private static string Blank = @"^$";
        private static string Total = @"^""To";
        private static string Sum = @"^""\d\d/\d\d/\d\d\d\d"","""",";
        private static string NewData = @"^""\d\d/\d\d/\d\d\d\d"",";
        private static string Data = @"^"""",""\w";
        private string[] SourceFiles = new string[100];
        private int FileCount;
        public string WkgDirectory;
        public DataSet MeterReads = new DataSet();
        public Regex RgxHeader = new Regex(Header);
        public Regex RgxData = new Regex(Data);
        public Regex RgxNewData = new Regex(NewData);
        public Regex RgxTotal = new Regex(Total);
        public Regex RgxBlank = new Regex(Blank);
        public Regex RgxSum = new Regex(Sum);
        public Queue<string> OutQueue = new Queue<string>();
        
        

        private int Classify(string s)
        {
            Match m;
            m= RgxHeader.Match(s);
            if (m.Success) return 0;    //Type 0 is a header line
            m= RgxBlank.Match(s);
            if (m.Success) return 1;    //Type 1 is a blank line
            m= RgxTotal.Match(s);
            if (m.Success) return 2;    //Type 2 is a totals line
            m= RgxSum.Match(s);
            if (m.Success) return 3;    //Type 3 is a summation line
            m= RgxData.Match(s);
            if (m.Success) return 4;    //Type 4 is a data line to save
            m= RgxNewData.Match(s);
            if (m.Success) return 5;    //Type 5 is a data line to save
            return 99;                  //Bad data
        }



Mind you, I was fairly drunk when I wrote it, but it works perfectly and I hesitate to change it. But it's still ugly.

I don't like having variables stuck in the Form when they're only used in one method. I'd slide all the declarations down into the Classify() method, but I'm afraid that this would cause them to be created and destroyed every time the method was called. That could really bog things down. My understanding of static methods is a bit fuzzy, but I suspect that if I put all the declarations in the method, and make the method static, this might eliminate the problem. Is that true, or should I just hide all the ugly bits in a region and get along with finishing the app?

Or is there a better way?
Will Rogers never met me.

AnswerRe: Style vs Performance Pin
PIEBALDconsult21-Dec-10 17:58
mvePIEBALDconsult21-Dec-10 17:58 
GeneralRe: Style vs Performance Pin
Roger Wright21-Dec-10 18:09
professionalRoger Wright21-Dec-10 18:09 
GeneralRe: Style vs Performance Pin
PIEBALDconsult22-Dec-10 3:31
mvePIEBALDconsult22-Dec-10 3:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.