Click here to Skip to main content
15,891,473 members
Home / Discussions / C#
   

C#

 
AnswerRe: I have a collum that is called "MountCT" Time type but for some reason when processing , times do not add up . Pin
Richard Andrew x6417-Dec-17 4:54
professionalRichard Andrew x6417-Dec-17 4:54 
Questioncompile error: The name 'HttpUtility' does not exist in the current context Pin
Member 1356965016-Dec-17 9:46
Member 1356965016-Dec-17 9:46 
AnswerRe: compile error: The name 'HttpUtility' does not exist in the current context Pin
Richard MacCutchan16-Dec-17 9:53
mveRichard MacCutchan16-Dec-17 9:53 
AnswerRe: compile error: The name 'HttpUtility' does not exist in the current context Pin
Eddy Vluggen16-Dec-17 10:47
professionalEddy Vluggen16-Dec-17 10:47 
QuestionStill fighting with the terminologies of unicode vs. encoding Pin
JustWatchLittle 16-Dec-17 5:43
professionalJustWatchLittle 16-Dec-17 5:43 
GeneralRe: Still fighting with the terminologies of unicode vs. encoding Pin
PIEBALDconsult16-Dec-17 6:04
mvePIEBALDconsult16-Dec-17 6:04 
GeneralRe: Still fighting with the terminologies of unicode vs. encoding Pin
JustWatchLittle 16-Dec-17 6:07
professionalJustWatchLittle 16-Dec-17 6:07 
SuggestionRe: Still fighting with the terminologies of unicode vs. encoding Pin
Richard Deeming18-Dec-17 2:19
mveRichard Deeming18-Dec-17 2:19 
GeneralRe: Still fighting with the terminologies of unicode vs. encoding Pin
PIEBALDconsult18-Dec-17 12:01
mvePIEBALDconsult18-Dec-17 12:01 
QuestionAdvice on Partial View Pin
sunsher16-Dec-17 0:36
sunsher16-Dec-17 0:36 
AnswerRe: Advice on Partial View Pin
Richard MacCutchan16-Dec-17 0:47
mveRichard MacCutchan16-Dec-17 0:47 
QuestionConvert .NET 4.5 method into .NET 2.0 using LinqBridge Pin
arnold_w14-Dec-17 1:39
arnold_w14-Dec-17 1:39 
This is a spin-off from the thread Efficiently sort the following? - Algorithms Discussion Boards , but specifically is about converting .NET 4.5 LINQ code into .NET 2.0 code using LinqBridge. The following code is using .NET 4.5 and works fine in Visual Studio 2013:
        public struct Record
        {
            public string column1 { get; set; }
            public string column2 { get; set; }
            public string column3 { get; set; }
        }

        public Form1()
        {
            InitializeComponent();

            Record[] UnsortedRecords =
            {
                new Record { column1 = "City",   column2 = "Florida",    column3 = "Miami"},
                new Record { column1 = "Animal", column2 = "Land",       column3 = "Dog"},
                new Record { column1 = "Animal", column2 = "Land",       column3 = "Rabbit"},
                new Record { column1 = "Food",   column2 = "Dessert",    column3 = "Chocolate Mousse"},
                new Record { column1 = "Food",   column2 = "Dinner",     column3 = "Hamburger"},
                new Record { column1 = "Animal", column2 = "Water",      column3 = "Fish"},
                new Record { column1 = "Animal", column2 = "Land",       column3 = "Cat"},
                new Record { column1 = "Food",   column2 = "Dessert",    column3 = "Cake"},
                new Record { column1 = "Animal", column2 = "Air",        column3 = "Bird"},
                new Record { column1 = "Food",   column2 = "Dessert",    column3 = "Ice Cream"},
                new Record { column1 = "Food",   column2 = "Dinner",     column3 = "Steak"},
                new Record { column1 = "Animal", column2 = "Water",      column3 = "Sea Lion"},
                new Record { column1 = "City",   column2 = "Texas",      column3 = "Austin"},
                new Record { column1 = "Food",   column2 = "Breakfast",  column3 = "Cereal"},
                new Record { column1 = "Food",   column2 = "Breakfast",  column3 = "Pancakes"},
                new Record { column1 = "City",   column2 = "Florida",    column3 = "Tampa"},
                new Record { column1 = "Animal"  , column2 = "Air",      column3 = "Fly"},
                new Record { column1 = "City",   column2 = "California", column3 = "San Francisco"},
                new Record { column1 = "Food",   column2 = "Breakfast",  column3 = "Bacon and Eggs"},
                new Record { column1 = "City",   column2 = "Texas",      column3 = "Dallas"},
                new Record { column1 = "City",   column2 = "Texas",      column3 = "Houston"},
                new Record { column1 = "City",   column2 = "California", column3 = "Los Angeles"},
                new Record { column1 = "Animal", column2 = "Water",      column3 = "Dolphin"},
                new Record { column1 = "Animal", column2 = "Air",        column3 = "Bee"},
                new Record { column1 = "City",   column2 = "Florida",    column3 = "Orlando"},
                new Record { column1 = "City",   column2 = "California", column3 = "San Diego"},
                new Record { column1 = "Food",   column2 = "Dinner",     column3 = "Lasagna" },
            };

            /* Sorted:
                "City" "Florida" "Miami"
                "City" "Florida" "Tampa"
                "City" "Florida" "Orlando"
                "City" "Texas" "Austin"
                "City" "Texas" "Dallas"
                "City" "Texas" "Houston"
                "City" "California" "San Francisco"
                "City" "California" "Los Angeles"
                "City" "California" "San Diego"
                "Animal" "Land" "Dog"
                "Animal" "Land" "Rabbit"
                "Animal" "Land" "Cat"
                "Animal" "Water" "Fish"
                "Animal" "Water" "Sea Lion"
                "Animal" "Water" "Dolphin"
                "Animal" "Air" "Bird"
                "Animal" "Air" "Fly"
                "Animal" "Air" "Bee"
                "Food" "Dessert" "Chocolate Mousse"
                "Food" "Dessert" "Cake"
                "Food" "Dessert" "Ice Cream"
                "Food" "Dinner" "Hamburger"
                "Food" "Dinner" "Steak"
                "Food" "Dinner" "Lasagna"
                "Food" "Breakfast" "Cereal"
                "Food" "Breakfast" "Bacon and Eggs"
                "Food" "Breakfast" "Pancakes"
            */
            IEnumerable<Record> SortedRecords = SortRecords(UnsortedRecords);
        }

        public static IEnumerable<Record> SortRecords(IEnumerable<Record> source)
        {
            return source
                .GroupBy(r => r.column1, (key, items) => items
                    .GroupBy(r => r.column2)
                    .SelectMany(g => g)
                )
                .SelectMany(g => g);
        }

The code above works great, but I need to run it in Visual Studio 2005, that is .NET 2.0. I have downloaded LinqBridge.dll ( LinqBridge ) and added a reference to it and I have tried the following, but I get build errors:
        public class Record
        {
            public string column1;
            public string column2;
            public string column3;

            public Record(string column1, string column2, string column3)
            {
                this.column1 = column1;
                this.column2 = column2;
                this.column3 = column3;
            }
        }

        public Form1()
        {
            InitializeComponent();
            System.Collections.ArrayList UnsortedRecords = new System.Collections.ArrayList();
            UnsortedRecords.Add(new Record("City",   "Florida",    "Miami"));
            UnsortedRecords.Add(new Record("Animal", "Land",       "Dog"));
            UnsortedRecords.Add(new Record("Animal", "Land",       "Rabbit"));
            UnsortedRecords.Add(new Record("Food",   "Dessert",    "Chocolate Mousse"));
            UnsortedRecords.Add(new Record("Food",   "Dinner",     "Hamburger"));
            UnsortedRecords.Add(new Record("Animal", "Water",      "Fish"));
            UnsortedRecords.Add(new Record("Animal", "Land",       "Cat"));
            UnsortedRecords.Add(new Record("Food",   "Dessert",    "Cake"));
            UnsortedRecords.Add(new Record("Animal", "Air",        "Bird"));
            UnsortedRecords.Add(new Record("Food",   "Dessert",    "Ice Cream"));
            UnsortedRecords.Add(new Record("Food",   "Dinner",     "Steak"));
            UnsortedRecords.Add(new Record("Animal", "Water",      "Sea Lion"));
            UnsortedRecords.Add(new Record("City",   "Texas",      "Austin"));
            UnsortedRecords.Add(new Record("Food",   "Breakfast",  "Cereal"));
            UnsortedRecords.Add(new Record("Food",   "Breakfast",  "Pancakes"));
            UnsortedRecords.Add(new Record("City",   "Florida",    "Tampa"));
            UnsortedRecords.Add(new Record("Animal"  , "Air",      "Fly"));
            UnsortedRecords.Add(new Record("City",   "California", "San Francisco"));
            UnsortedRecords.Add(new Record("Food",   "Breakfast",  "Bacon and Eggs"));
            UnsortedRecords.Add(new Record("City",   "Texas",      "Dallas"));
            UnsortedRecords.Add(new Record("City",   "Texas",      "Houston"));
            UnsortedRecords.Add(new Record("City",   "California", "Los Angeles"));
            UnsortedRecords.Add(new Record("Animal", "Water",      "Dolphin"));
            UnsortedRecords.Add(new Record("Animal", "Air",        "Bee"));
            UnsortedRecords.Add(new Record("City",   "Florida",    "Orlando"));
            UnsortedRecords.Add(new Record("City",   "California", "San Diego"));
            UnsortedRecords.Add(new Record("Food",   "Dinner",     "Lasagna" ));

            /* Sorted:
                "City" "Florida" "Miami"
                "City" "Florida" "Tampa"
                "City" "Florida" "Orlando"
                "City" "Texas" "Austin"
                "City" "Texas" "Dallas"
                "City" "Texas" "Houston"
                "City" "California" "San Francisco"
                "City" "California" "Los Angeles"
                "City" "California" "San Diego"
                "Animal" "Land" "Dog"
                "Animal" "Land" "Rabbit"
                "Animal" "Land" "Cat"
                "Animal" "Water" "Fish"
                "Animal" "Water" "Sea Lion"
                "Animal" "Water" "Dolphin"
                "Animal" "Air" "Bird"
                "Animal" "Air" "Fly"
                "Animal" "Air" "Bee"
                "Food" "Dessert" "Chocolate Mousse"
                "Food" "Dessert" "Cake"
                "Food" "Dessert" "Ice Cream"
                "Food" "Dinner" "Hamburger"
                "Food" "Dinner" "Steak"
                "Food" "Dinner" "Lasagna"
                "Food" "Breakfast" "Cereal"
                "Food" "Breakfast" "Bacon and Eggs"
                "Food" "Breakfast" "Pancakes"
            */
            System.Collections.ArrayList SortedRecords = SortRecords(UnsortedRecords);
        }

        // You can either replace the ArrayList with a List<T>[^], or use the Cast[^] or OfType[^] 
        // methods to convert it to an IEnumerable<T>.
        public static IEnumerable<Record> SortRecords(IEnumerable<Record> source)
        {
            IEnumerable<IEnumerable<Record>> groupT = System.Linq.Enumerable.GroupBy<Record, string, IEnumerable<Record>>(source,
                delegate(Record r) { return r.column1; },
                delegate(string key, IEnumerable<Record> items)
                {
                    IEnumerable<IGrouping<string, Record>> groupH = System.Linq.Enumerable.GroupBy<Record, string>(items, delegate(Record r) { return r.column2; });
                    return System.Linq.Enumerable.SelectMany<IEnumerable<Record>, Record>(groupH, delegate(IEnumerable<Record> g) { return g; });
                });

            return System.Linq.Enumerable.SelectMany<IEnumerable<Record>, Record>(groupT, delegate(IEnumerable<Record> g) { return g; });
        }

Can someone please help me get this work?
AnswerRe: Convert .NET 4.5 method into .NET 2.0 using LinqBridge Pin
Richard Deeming14-Dec-17 2:39
mveRichard Deeming14-Dec-17 2:39 
GeneralRe: Convert .NET 4.5 method into .NET 2.0 using LinqBridge Pin
arnold_w14-Dec-17 3:15
arnold_w14-Dec-17 3:15 
GeneralRe: Convert .NET 4.5 method into .NET 2.0 using LinqBridge Pin
Richard Deeming14-Dec-17 3:30
mveRichard Deeming14-Dec-17 3:30 
GeneralRe: Convert .NET 4.5 method into .NET 2.0 using LinqBridge Pin
arnold_w14-Dec-17 4:14
arnold_w14-Dec-17 4:14 
GeneralRe: Convert .NET 4.5 method into .NET 2.0 using LinqBridge Pin
arnold_w14-Dec-17 5:19
arnold_w14-Dec-17 5:19 
SuggestionRe: Convert .NET 4.5 method into .NET 2.0 using LinqBridge Pin
Richard Deeming14-Dec-17 6:17
mveRichard Deeming14-Dec-17 6:17 
GeneralRe: Convert .NET 4.5 method into .NET 2.0 using LinqBridge Pin
BillWoodruff15-Dec-17 11:06
professionalBillWoodruff15-Dec-17 11:06 
GeneralRe: Convert .NET 4.5 method into .NET 2.0 using LinqBridge Pin
arnold_w15-Dec-17 20:29
arnold_w15-Dec-17 20:29 
QuestionNeed to understand work assigned to me Pin
nisss13-Dec-17 20:13
nisss13-Dec-17 20:13 
AnswerRe: Need to understand work assigned to me Pin
OriginalGriff13-Dec-17 20:36
mveOriginalGriff13-Dec-17 20:36 
GeneralRe: Need to understand work assigned to me Pin
nisss14-Dec-17 0:11
nisss14-Dec-17 0:11 
GeneralRe: Need to understand work assigned to me Pin
OriginalGriff14-Dec-17 0:32
mveOriginalGriff14-Dec-17 0:32 
GeneralRe: Need to understand work assigned to me Pin
nisss14-Dec-17 0:52
nisss14-Dec-17 0:52 

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.