Click here to Skip to main content
15,888,977 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: Style vs Performance Pin
Roger Wright22-Dec-10 4:01
professionalRoger Wright22-Dec-10 4:01 
GeneralRe: Style vs Performance Pin
PIEBALDconsult22-Dec-10 14:28
mvePIEBALDconsult22-Dec-10 14:28 
GeneralRe: Style vs Performance Pin
Roger Wright22-Dec-10 14:39
professionalRoger Wright22-Dec-10 14:39 
AnswerRe: Style vs Performance Pin
Luc Pattyn21-Dec-10 18:25
sitebuilderLuc Pattyn21-Dec-10 18:25 
AnswerRe: Style vs Performance Pin
Pete O'Hanlon21-Dec-10 22:28
mvePete O'Hanlon21-Dec-10 22:28 
GeneralRe: Style vs Performance Pin
PIEBALDconsult22-Dec-10 3:09
mvePIEBALDconsult22-Dec-10 3:09 
AnswerRe: Style vs Performance Pin
Keith Barrow21-Dec-10 22:56
professionalKeith Barrow21-Dec-10 22:56 
GeneralRe: Style vs Performance Pin
PIEBALDconsult22-Dec-10 3:19
mvePIEBALDconsult22-Dec-10 3:19 
QuestionMessage Removed Pin
21-Dec-10 16:45
Aseem Sharma21-Dec-10 16:45 
AnswerRe: Register a 32 bit ATL service on Windows7-64 bit? Pin
Dave Kreskowiak21-Dec-10 18:21
mveDave Kreskowiak21-Dec-10 18:21 
GeneralRe: Register a 32 bit ATL service on Windows7-64 bit? Pin
Aseem Sharma21-Dec-10 19:12
Aseem Sharma21-Dec-10 19:12 
QuestionI'm looking for ideas or examples on programmatically reading the contents inside of a remote desktop window Pin
turbosupramk321-Dec-10 11:22
turbosupramk321-Dec-10 11:22 
AnswerRe: I'm looking for ideas or examples on programmatically reading the contents inside of a remote desktop window Pin
PIEBALDconsult21-Dec-10 15:59
mvePIEBALDconsult21-Dec-10 15:59 
GeneralRe: I'm looking for ideas or examples on programmatically reading the contents inside of a remote desktop window Pin
turbosupramk321-Dec-10 16:24
turbosupramk321-Dec-10 16:24 

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.