Click here to Skip to main content
15,905,233 members
Home / Discussions / C#
   

C#

 
QuestionAndroid Studio: How can disable My applications in mobile when i run my application? Pin
Dr Kasa10-Oct-16 3:54
Dr Kasa10-Oct-16 3:54 
AnswerRe: Android Studio: How can disable My applications in mobile when i run my application? Pin
Pete O'Hanlon10-Oct-16 4:11
mvePete O'Hanlon10-Oct-16 4:11 
AnswerRe: Android Studio: How can disable My applications in mobile when i run my application? Pin
OriginalGriff10-Oct-16 4:11
mveOriginalGriff10-Oct-16 4:11 
GeneralRe: Android Studio: How can disable My applications in mobile when i run my application? Pin
Eddy Vluggen10-Oct-16 4:38
professionalEddy Vluggen10-Oct-16 4:38 
GeneralRe: Android Studio: How can disable My applications in mobile when i run my application? Pin
OriginalGriff10-Oct-16 4:42
mveOriginalGriff10-Oct-16 4:42 
GeneralRe: Android Studio: How can disable My applications in mobile when i run my application? Pin
Eddy Vluggen10-Oct-16 5:02
professionalEddy Vluggen10-Oct-16 5:02 
GeneralRe: Android Studio: How can disable My applications in mobile when i run my application? Pin
OriginalGriff10-Oct-16 5:53
mveOriginalGriff10-Oct-16 5:53 
QuestionLong Path Exception when adding attachments Pin
NJdotnetdev10-Oct-16 3:00
NJdotnetdev10-Oct-16 3:00 
AnswerRe: Long Path Exception when adding attachments Pin
F-ES Sitecore10-Oct-16 3:16
professionalF-ES Sitecore10-Oct-16 3:16 
AnswerRe: Long Path Exception when adding attachments Pin
NJdotnetdev12-Oct-16 4:35
NJdotnetdev12-Oct-16 4:35 
GeneralRe: Long Path Exception when adding attachments Pin
Eddy Vluggen12-Oct-16 7:03
professionalEddy Vluggen12-Oct-16 7:03 
GeneralRe: Long Path Exception when adding attachments Pin
NJdotnetdev17-Oct-16 2:23
NJdotnetdev17-Oct-16 2:23 
Questionan "injection" problem/challenge Pin
BillWoodruff9-Oct-16 22:45
professionalBillWoodruff9-Oct-16 22:45 
AnswerRe: an "injection" problem/challenge Pin
Richard Deeming10-Oct-16 3:21
mveRichard Deeming10-Oct-16 3:21 
GeneralRe: an "injection" problem/challenge Pin
BillWoodruff10-Oct-16 4:56
professionalBillWoodruff10-Oct-16 4:56 
Questionhow to read mbr Pin
Member 124586219-Oct-16 2:00
Member 124586219-Oct-16 2:00 
AnswerRe: how to read mbr Pin
NotPolitcallyCorrect9-Oct-16 2:19
NotPolitcallyCorrect9-Oct-16 2:19 
AnswerRe: how to read mbr Pin
OriginalGriff9-Oct-16 2:24
mveOriginalGriff9-Oct-16 2:24 
QuestionResistor color code Pin
Pavlex48-Oct-16 23:34
Pavlex48-Oct-16 23:34 
AnswerRe: Resistor color code Pin
Jochen Arndt9-Oct-16 0:44
professionalJochen Arndt9-Oct-16 0:44 
GeneralRe: Resistor color code Pin
Pavlex49-Oct-16 0:48
Pavlex49-Oct-16 0:48 
GeneralRe: Resistor color code Pin
Jochen Arndt9-Oct-16 1:09
professionalJochen Arndt9-Oct-16 1:09 
GeneralRe: Resistor color code Pin
Pavlex49-Oct-16 1:11
Pavlex49-Oct-16 1:11 
C#
private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text == "4")
            {
                if (textBox1.Text == "0")
                    MessageBox.Show("Otpornost mora biti veca od nule", "Otpornost", MessageBoxButtons.OK, MessageBoxIcon.Error);
 
              //  var black = Color.Black;
 
 
 
                var colours = new string[] { "Black", "Brown", "Red", "Orange", "Yellow", "Green", "Blue", "Violet", "Grey", "Silver", "Gold" };
                var factorDictionary = new Dictionary<char, int>() { { 'R', 1 }, { 'K', 1000 }, { 'M', 1000000 }, { 'G', 1000000000 } };
                string res = string.Empty;
 
                while (string.IsNullOrEmpty(res))
                {
                  //  MessageBox.Show("Enter resistor value (use R, K, M ,G notation for .): ");
                    res = textBox1.Text;
                }
 
                var lastChar = res.Last();
                var isUnitCorrect = factorDictionary.ContainsKey(lastChar);
                var value = res.Substring(0, res.Length - 1);
                var isValueCorrect = !value.Any(x => !char.IsDigit(x));
 
                if (isUnitCorrect && isValueCorrect)
                {
                    int mul = factorDictionary[lastChar];
                    double val = double.Parse(value) * mul;
                    int third = 0;
 
                    if (val < 1)
                    {
                        val *= 100;
                        third = 9;
                    }
                    else if (val < 10)
                    {
                        val *= 10;
                        third = 10;
                    }
 
                    res = val.ToString();
 
                    if (res.Count() > 11)
                        MessageBox.Show("Invalid value");
                    else
                    {
                        label15.BackColor = Color.FromName(colours[res[0] - '0']);
                        label16.BackColor = Color.FromName(colours[res[1] - '0']);
                        label17.BackColor = Color.FromName(colours[third != 0 ? third : res.Count() - 2]);
                    }
                }
                else
                    MessageBox.Show("Invalid value!");
            }
        }

GeneralRe: Resistor color code Pin
Pavlex49-Oct-16 7:31
Pavlex49-Oct-16 7:31 
GeneralRe: Resistor color code Pin
Pavlex49-Oct-16 12:21
Pavlex49-Oct-16 12:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.