Posts

How to convert datatable to List using c# with generics

First we can start Generic methods creations like below manner   public static List<T> ConvertDataTable<T>(DataTable dt)         {             List<T> lstData = new List<T>();             foreach (DataRow row in dt.Rows)             {                 T item = GetInnerItem<T>(row);                 lstData.Add(item);             }             return lstData;         }  private static T GetInnerItem<T>(DataRow dr)         {             Type temp = typeof(T);             T obj = Activator.CreateInstance<T>();             foreach (DataColumn colu...

ATM Money pumping Program using c#

Hi all, The below program is to get the Currency notes count using User Input. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BasicCalculations { class Program { static void Main(string[] args) { //Currecy Exxisting inside Mechine List<int> lstCurrencies = new List<int>() { 1, 2, 5, 10, 20, 50, 100, 500, 1000, 2000 }; int inputValue = 20041;// User Input foreach (var currecy in lstCurrencies.OrderByDescending(a => a).ToList()) { if ((inputValue / currecy) != 0) Console.Write("your base curency is  " + currecy + ": Expected currecy Count =" + inputValue / currecy + "\n"); // Print Data inputValue = inputValue % currecy; if (inputValue == 0) break; // Break Loop } Console.ReadKey(); } } }

How to split the String values with a word in C#

string str="srinivas<br / >nivas <br / >Sri" Result : List<string> strNames = str.Split(new[] { "<br />" },StringSplitOptions.None).ToList(); Distincr names: List<string> strNames = str.Split(new[] { "<br />" },StringSplitOptions.None).Distinct().ToList();

How to add to List of Strings in one dictonary like dictonary in c#

First u can take 2 list of Strings Var a =new List<string>(){"API","UI"} ; var b=new List<string> (){"Application Programming Interface","User Interface"} ; Result: ===== API = Application Programming Interface UI = User Interface Firs you can create on extension method for this       public static class ExtentionMethod { public static void YDR<T>(this IEnumerable dr,Action<T,int> y) { int initials = 0; foreach (T item in dr) { y(item,initials ++); } } }          public static Dictionary<TKey,TValue> Adding<TKey, TValue>(IEnumerable<TKey> keys,IEnumerable<TValue> values) { var dictonary = new Dictionary<TKey,TValue>(); keys.YDR<TKey>((x,i) => { dictonary .Add(x,values.ElementAt(i)); }); return dictonary; } Use case : ======= Create a class and use this method public Dictionary<...

Convert Time to decimal in C#

Can we take the time value is roughly at 10:30:00 Type1   decimal output= Convert . ToDecimal ( TimeSpan . Parse ( "10:30" ). TotalHours ); Net Approch will be 2 nd Type is var startTime= TimeSpan . Parse ( "10:30" ) ; var endTime=TimeSpan . Parse ( "11:30" ); var result = endTime - startTime; decimal output= result.Hours+result.Minites/60; Here minites should be reater than 0.

Angular sample program with componets 1.5.2 angular

Image
https://drive.google.com/file/d/0B7xqx0jzWa3TbWJoeGxVY0tGLTA/view?usp=sharing If u need to customize this code .u procesed remain thanks you.

How to write Pure java script Program?

Image
Create  the Below  folder structure app.js: ==== function submit() {     var name = document.getElementById("txtName").value;     var code = document.getElementById("txtCode").value;     console.log(name + code); } function turnOffLight() {     var a, b, c;     a = 10;     b = 12;     document.getElementById("tagDisplay").innerHTML = a + b; } function turnOnLight() {     /*Comment Implementation       document.getElementById("tagInnerHtmlBasicTag").innerHTML = 'Sreenivas';     */     var x, y;     x = y;     x += y;//x=x+y;     x -= y;//x=x-y;     x *= y;//x=x*y;     x /= y;//x=x/y;     x = 10;     y = 10;     console.log(x | y);     console.log(x ** y);     console.log(x ^ y);     console.log(x >>> y); ...