Friday 3 March 2017

Find out the second highest no in array.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ArrayManipulation
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] myarr = new Int32[] { 1, 8, 9, 88, 77, 76, 22, 225 };
            int mxval = 0;
            int secondHv = 0;
            int sum = 0;
            int count = 0;
            int avg = 0;
            foreach (int i in myarr)
            {

                if (i > mxval)
                {
                    secondHv = mxval;
                    mxval = i;

                }
                else if (i > secondHv)
                    secondHv = i;
                sum += i;
                count++;
                avg = sum / count;
              
                        }
            Console.WriteLine(mxval);
            Console.WriteLine(secondHv);
            Console.WriteLine(sum);
            Console.WriteLine(count);
            Console.WriteLine(avg);
            Console.ReadLine();
        }
    }

}

How to get logged in User's Security Roles using Java Script in dynamic CRM 365.

 function GetloggedUser () {     var roles = Xrm.Utility.getGlobalContext().userSettings.roles;      if (roles === null) return false;      ...