Thursday, 17 November 2016

Iqs


1) How can we do from Intranet application to internet.

2)How can you do authentication in MVC

3)Data annotation in mvc
4)how can we call client side validations in dataannotations
5)How can we bind data in MVC flow?
6)ref and out parameters
7)call sp in Entity framework
8)what is model binders?
9)How and When to use `async` and `await`
10) State management in MVC
11)Types of sessions?
12)Locking in mvc?
13)User 1 is access one table at same time user 2 also access same table he is doing update on that     table,   how can we prevent that one?
14)MSIL,CLR
15)  How and When to use `async` and `await` .

16)How to remove duplicates in array list

   Remove duplicate values through List Contain method
public string[] RemoveDuplicates(string[] inputArray)
{
    List<string> distinctArray = new List<string>();
    foreach (string element in inputArray)
    {
        if (!distinctArray.Contains(element))
            distinctArray.Add(element);
    }

    return distinctArray.ToArray<string>();
}

Delete Duplicate elements through ArrayList Contain method
public string[] RemoveDuplicates(string[] inputArray)
{
    System.Collections.ArrayList distinctArray = new System.Collections.ArrayList();

    foreach (string element in inputArray)
    {
        if (!distinctArray.Contains(element))
            distinctArray.Add(element);
    }

    return (string[])distinctArray.ToArray(typeof(string));

}
------------------------------------
Remove Duplicate number / record of array through Linq Distinct method
public string[] RemoveDuplicates(string[] inputArray)
{
    return inputArray.Distinct().ToArray<string>();
}

public int[] RemoveDuplicates(int[] inputArray)
{
    return inputArray.Distinct().ToArray<int>();

}

Removing Duplicate entries through traditional for loop
public string[] RemoveDuplicates(string[] inputArray)
{

    int length = inputArray.Length;
    for (int i = 0; i < length; i++)
    {
        for (int j = (i + 1); j < length; )
        {
            if (inputArray[i] == inputArray[j])
            {
                for (int k = j; k < length - 1; k++)
                    inputArray[k] = inputArray[k + 1];
                length--;
            }
            else
                j++;
        }
    }

    string[] distinctArray = new string[length];
    for (int i = 0; i < length; i++)
        distinctArray[i] = inputArray[i];

    return distinctArray;

}

--------------------------------------------------

Calling of RemoveDuplicates method -

string[] inputArray = { "array", "array", "distinct", "elememnt", "remove", "distinct", "delete", "delete", "delete" };
string[] distinctArray = RemoveDuplicates(inputArray);


No comments:

Post a Comment