Collection

1.What is an Array ? What are different ways of writing an Array ?
Array is a datastructure that stores a collection of value that are of same data type.
diff ways of writing an array are-
a)specify the data length in declaration.
int [] count= new int[5];

b) int[] count = new int[] { 1, 2, 3 };
skip the length but have to specify the value.

c)int[] count = new int[2] { 1, 2, 3 };
both a and b. one thing should be taken care here the length of int array should be equal
to number of values specified.


2.Array is reference type or value type ?
Reference Type 

3.How do you search an item in an Array ?
The BinarySearch static method of Array class can be used to search for an item in a array. . The method takes at least two parameters - an array and an object (the item you are looking for). If an item found in an array, the method returns the index of the item (based on first item as 0th item),  else method returns a negative value.
eg- 
 string[] name = new string[] { "chai", "alex", "dave" };         
int i=Array.BinarySearch(name, "dfsdf");  

i returns a negative value.
 
4.How to achieve Deep copy and Shallow copy using Array ?
Deep Copy-- By using Array.CopyTo
Shallow Copy---Array.Clone()


5.What are different types of an Array ?
a) Single dimensional Array
b) Multidimensional Array
c) Jaggd Array


6.Can diff data types be stored in a single Array?
No
7.Where does array index starts ?
Array index starts at Zero.
Suppose you have int [] count= {1,2,3} then
int[0] will give you "1".

8.Give an example of accessing Array using foreach loop.
 string[] name = new string[] { "chai", "alex", "dave" };           
 foreach (string a in name)

{
    
  Console.WriteLine(a.ToString());               
}

9. How do you sort an item in Array in reverse order ?
Use Count and Reverse property of an array.
eg-
int[] count = new int[] { 1, 2, 3,6,8,4 };
 Array.Sort(count);
 Array.Reverse(count);


10.Find the maximum no in an array.
you can use the property of array called Max or use the below algo-


11.Convert arraylist to string array 
Suppose you have a arraylist say with 3 string values- a[0]-name,a[1]-age,a[2]-gender.After converting using below code it will look like

string.Join(",",(string[])a.ToArray(typeof(string)))

string a=name,age,gender

 




23 comments:

  1. 6.Can diff data types be stored in a single Array?

    Its yes, it can be stored

    ReplyDelete
  2. Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article. thank you for sharing such a great blog with us.
    microsoft azure training in bangalore
    rpa training in bangalore
    best rpa training in bangalore
    rpa online training

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Thanks For Sharing Your Information Please Keep UpDating Us The Information Shared Is Very Valuable Time Went On Just Reading The Article Python Online Training Devops Online Training
    Aws Online Training DataScience Online Training
    Hadoop Online Training

    ReplyDelete
  5. Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care and we take your comments to heart.As always, we appreciate your confidence and trust in us
    Data Science training in Chennai
    Data science training in Bangalore
    Data science online training

    ReplyDelete
  6. Whoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.
    Data Science Training in Bangalore
    Data Science Training institute in Bangalore

    ReplyDelete
  7. Does your blog have a contact page? I’m having problems locating it but, I’d like to shoot you an email. I’ve got some recommendations for your blog you might be interested in hearing.
    Selenium training in chennai
    Selenium training in bangalore
    Selenium training institute in bangalore

    ReplyDelete
  8. I really like your blog. You make it interesting to read and entertaining at the same time. I cant wait to read more from you.
    DevOps Training in chennai

    DevOps Training in Bangalore

    Tableau Training in Chennai

    Tableau Training in Bangalore

    ReplyDelete
  9. I like viewing web sites which comprehend the price of delivering the excellent useful resource free of charge. I truly adored reading your posting. Thank you!

    artificial Intelligence course

    machine learning courses in mumbai

    ReplyDelete
  10. i am enjoyed while reading your article. Thank you so much for this incredible guide, Keep Sharing
    AWS Training in Hyderabad

    ReplyDelete
  11. The context has been explained really well. Looking forward to see more of such informative updates.Thank you For Sharing this Blog. The Blog is really Impressive Fetch the Information easily from this Content.
    Data Science Training In Chennai

    Data Science Online Training In Chennai

    Data Science Training In Bangalore

    Data Science Training In Hyderabad

    Data Science Training In Coimbatore

    Data Science Training

    Data Science Online Training


    ReplyDelete
  12. I wanted to leave a little comment to support you and wish you a good continuation. Wishing you the best of luck for all your blogging efforts.
    machine learning courses in bangalore

    ReplyDelete
  13. Thanks For sharing a nice post about all Course.It is very helpful and for us.
    Workday training in bangalore

    ReplyDelete
  14. Thanks for sharing a useful info. I would also suggest for Data Science course with Real time experience, visit: https://socialprachar.com/data-science-training-in-bengaluru/

    ReplyDelete
  15. if ur interested in learning AWS course please visit our websiteAWS Training in Hyderabad

    ReplyDelete
  16. The AWS certification course has become the need of the hour for freshers, IT professionals, or young entrepreneurs. AWS is one of the largest global cloud platforms that aids in hosting and managing company services on the internet. It was conceived in the year 2006 to service the clients in the best way possible by offering customized IT infrastructure. Due to its robustness, Digital Nest added AWS training in Hyderabad under the umbrella of other courses.

    ReplyDelete
  17. Really fantastic blog. Informative and knowledgeable content. This blog is useful to many people. Keep sharing more stuff like this. Thank you.
    Data Science Training

    ReplyDelete
  18. I recently came across your article and have been reading along. I want to express my admiration of your writing skill and ability to make readers read from the beginning to the end. I would like to read newer posts and to share my thoughts with you.
    data science training institute in hyderabad

    ReplyDelete
  19. Thank you for sharing your knowledge and expertise with the community. Start on a  AWS journey.

    ReplyDelete