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

C#

 
QuestionSnmp packet format Pin
Member 788151814-Apr-12 1:42
Member 788151814-Apr-12 1:42 
QuestionRe: Snmp packet format Pin
Eddy Vluggen15-Apr-12 0:44
professionalEddy Vluggen15-Apr-12 0:44 
AnswerRe: Snmp packet format Pin
Member 788151815-Apr-12 6:51
Member 788151815-Apr-12 6:51 
AnswerRe: Snmp packet format Pin
jschell16-Apr-12 12:26
jschell16-Apr-12 12:26 
AnswerRe: Snmp packet format Pin
Member 788151818-Apr-12 16:24
Member 788151818-Apr-12 16:24 
QuestionUpdating application on internet Pin
jojoba201113-Apr-12 19:54
jojoba201113-Apr-12 19:54 
AnswerRe: Updating application on internet Pin
Abhinav S13-Apr-12 20:33
Abhinav S13-Apr-12 20:33 
QuestionIEnumerable - why does this code work? Pin
jeramyRR13-Apr-12 19:11
jeramyRR13-Apr-12 19:11 
So basically the code below just creates an XML document in memory and then parses it and spits the values back out. The question I have is about the IEnumerable<xelement> statements. I never implemented a class that uses the interface, but yet it still works in this code. Does the compiler automagically create a container or something? How does this work? Does this work for all interfaces?

C#
class Program
   {
       static void Main(string[] args)
       {
           XDocument employeeDoc = 
               new XDocument(
                   new XElement("Employees",
                       new XElement("Employee",
                           new XElement("Name" , "Bob Smith"),
                           new XElement("Phone" , "408-555-1000"),
                           new XElement("Phone" , "408-555-1001")),
                       new XElement("Employee",
                           new XElement("Name", "Sally Jones"),
                           new XElement("Phone", "415-555-2000"),
                           new XElement("Phone", "415-555-2001"))
                           )
               );

           XElement root = employeeDoc.Element("Employees");
           IEnumerable<XElement> employees = root.Elements();

           foreach (XElement emp in employees)
           {
               XElement empNameNode = emp.Element("Name");
               Console.WriteLine(empNameNode.Value);

               IEnumerable<XElement> empPhones = emp.Elements("Phone");
               foreach (XElement phone in empPhones)
               {
                   Console.WriteLine("   {0}", phone.Value);
               }
           }

       }
   }

AnswerRe: IEnumerable - why does this code work? Pin
Karthik Harve13-Apr-12 19:48
professionalKarthik Harve13-Apr-12 19:48 
GeneralRe: IEnumerable - why does this code work? Pin
jeramyRR13-Apr-12 20:19
jeramyRR13-Apr-12 20:19 
AnswerRe: IEnumerable - why does this code work? Pin
VJ Reddy13-Apr-12 20:44
VJ Reddy13-Apr-12 20:44 
GeneralRe: IEnumerable - why does this code work? Pin
jeramyRR13-Apr-12 20:46
jeramyRR13-Apr-12 20:46 
GeneralRe: IEnumerable - why does this code work? Pin
VJ Reddy13-Apr-12 20:50
VJ Reddy13-Apr-12 20:50 
GeneralRe: IEnumerable - why does this code work? Pin
Abhinav S13-Apr-12 20:49
Abhinav S13-Apr-12 20:49 
GeneralRe: IEnumerable - why does this code work? Pin
VJ Reddy13-Apr-12 20:51
VJ Reddy13-Apr-12 20:51 
GeneralRe: IEnumerable - why does this code work? Pin
Wonde Tadesse14-Apr-12 13:53
professionalWonde Tadesse14-Apr-12 13:53 
GeneralRe: IEnumerable - why does this code work? Pin
VJ Reddy14-Apr-12 14:19
VJ Reddy14-Apr-12 14:19 
AnswerRe: IEnumerable - why does this code work? Pin
Abhinav S13-Apr-12 20:41
Abhinav S13-Apr-12 20:41 
GeneralRe: IEnumerable - why does this code work? Pin
VJ Reddy13-Apr-12 20:45
VJ Reddy13-Apr-12 20:45 
GeneralRe: IEnumerable - why does this code work? Pin
jeramyRR13-Apr-12 20:46
jeramyRR13-Apr-12 20:46 
GeneralRe: IEnumerable - why does this code work? Pin
Abhinav S13-Apr-12 20:48
Abhinav S13-Apr-12 20:48 
QuestionHow to provide the articles in nice way Pin
Anurag Sarkar13-Apr-12 9:21
Anurag Sarkar13-Apr-12 9:21 
AnswerRe: How to provide the articles in nice way Pin
PIEBALDconsult13-Apr-12 9:28
mvePIEBALDconsult13-Apr-12 9:28 
GeneralRe: How to provide the articles in nice way Pin
Anurag Sarkar13-Apr-12 9:37
Anurag Sarkar13-Apr-12 9:37 
AnswerRe: How to provide the articles in nice way Pin
Abhinav S13-Apr-12 20:43
Abhinav S13-Apr-12 20:43 

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.