Farhan Sarwar

Farhan Sarwar

How to Merge two or more Lists in C#

Suppose we have 2 Lists of Products, and we want to make it one List. List<Product> products1 = GetProducts(cid1); List<Product> products2 = GetProducts(cid2); One way is to iterate the 2nd List, and add all elements to the 1st List, or iterate both…

Make a reserved keyword a Variable name in C#

Reserved keyword as variable name

In C# the ‘@‘ character is used to denote literals that explicitly do not adhere to the relevant rules in the language specification. If we use a keyword as the name for an identifier, we get a compile-time error “identifier expected,…

Remove item from List while iterating – C#

Remove items from list while iterating

Removing elements from List<> while iterating over the List, someone may simply try: foreach(char c in list)  {      list.Remove(c);  } But, When we execute this code, we will get System.InvalidOperationException with the message “Collection was modified; enumeration  operation may not execute.” The reason is: The…

Get System IP Address using VBScript

vbscript for getting IP

Following is the code to get the IP Address of the system using VBScript (.vbs) dim Nics, StrIP Set Nics= GetObject(“winmgmts:”) .InstancesOf(“Win32_NetworkAdapterConfiguration”) For Each Nic in Nics if Nic.IPEnabled then StrIP = Nic.IPAddress(i) Wscript.Echo “IP Address: “&StrIP wscript.quit end if…

Parse and get xml node using php

XML Parsing using PHP

XML parsing essentially means traversing through the XML and returning the data. Nowadays, A number of web services return data in JSON format, but a large number still use XML. There are two methods for loading XML, the simplexml_load_file() will load the…