C # Analysis of instances of different colors loaded with even and odd numbers on the table

Source: Internet
Author: User
This article mainly introduces C # according to the table even, odd load different colors, the need for friends can refer to the following


 Even randomized random evenranm = new Random ();  Odd stochastic random oddranm = new Random (); string[] Listcolor = new string[] {"#2BB669", "#FF5750", "#39AFEA", "#9A0089", "#00CC6A", "#717FF9", "#4A5459", "#00B7C    3 "," #0078D7 "," #E2AB12 "};   Record form execution/even number set list<string> evennum=new list<string> ();   Odd number Set list<string> Oddnum = new list<string> ();    for (int j = 0; J < Listcolor.count (); j + +) {if (j 2 = = 0) {evennum.add (listcolor[j]);    } else {Oddnum.add (listcolor[j]);   }}//Assign a value to list list<role_info> list = new list<role_info> (); List.   ADD (New Role_info () {role_name= "Super admin"}); List.   ADD (New Role_info () {role_name= "Super User"}); List.   ADD (New Role_info () {role_name = "teacher"}); List.   ADD (New Role_info () {role_name= "Dean"}); List.   ADD (New Role_info () {role_name = "headmaster"}); List.   ADD (New Role_info () {role_name = "normal User"}); List.   ADD (New Role_info () {role_name = "Test"}); List. ADD (New Role_info () {Role_name = "User"}); List.   ADD (New Role_info () {role_name = "test User"}); List.   ADD (New Role_info () {role_name = "Student"}); List.   ADD (New Role_info () {role_name = "Teacher"}); List.   ADD (New Role_info () {role_name = "visitor"}); List.    ADD (New Role_info () {role_name = "student"});   Button Btn=null; for (int i = 0; i < list. Count;    i++) {btn = new Fbutton ();     if (i%2==0) {int even = Evenranm.next (Evennum.count ()); Btn. Content=list[i].     Role_name; Btn.    Background = new SolidColorBrush ((Color) colorconverter.convertfromstring (Evennum[even]);     } else {int odd = Oddranm.next (Oddnum.count ()); Btn. Content=list[i].     Role_name; Btn.     Background = new SolidColorBrush ((Color) colorconverter.convertfromstring (oddnum[odd]); }}//Finally adding the button to the control

summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.