Official Everybody Edits Forums

Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?

You are not logged in.

#1 Before February 2015

Vitalijus
Member
From: Lithuania
Joined: 2015-02-15
Posts: 1,384
Website

Caps lock

Hi how can I type player name with caps lock? I mean my bot does this

Vitalijus: !example
Bot: vitalijus

I want to do like this

Vitalijus: !example
Bot: VITALIJUS

I didn't knew how to tell you so I just typed.


wn7I7Oa.png

Offline

#2 Before February 2015

Buzzerbee
Forum Admin
From: Texas, U.S.A.
Joined: 2015-02-15
Posts: 4,571

Re: Caps lock

If I understand the question correctly, in C#, you can use the String.ToUpper() method to convert the text to uppercase. For example:

Console.WriteLine("vitalijus".ToUpper()); //returns VITALIJUS

You can also use String.ToLower() to make a string lowercase.

Hope that answers your question.

Last edited by BuzzerBee (Jan 17 2015 1:44:45 pm)


TdQRyz3.png
https://wiki.everybodyedits.com/images/5/5d/135_bee

Offline

#3 Before February 2015

lrussell
Member
From: Saturn's Titan
Joined: 2015-02-15
Posts: 843
Website

Re: Caps lock

>Basic C# 2015
I feel like no one can be bothered to Google.

Offline

#4 Before February 2015

Processor
Member
Joined: 2015-02-15
Posts: 2,246

Re: Caps lock

Wow, time to add more useful/useless information!

I was bored and created a FormatProvider class. <3

public class ToUpperStringFormat : IFormatProvider, ICustomFormatter
{
    public object GetFormat(Type formatType)
    {
        if (formatType == typeof(ICustomFormatter)) return this;
        else return null;
    }

    public string Format(string format, object arg, IFormatProvider formatProvider)
    {
        string result = arg.ToString();
        switch (format.ToUpper())
        {
            case "U":
                return result.ToUpper();
            default:
                return result;
        }
    }
}

Now you can do:

var user = "benjaminsen"; 
var message = "hello"; 
var output = String.Format(new ToUpperStringFormat(), "[Bot] {0:U}: {1}", user, message); 
// output = [Bot] BENJAMINSEN: hello

So gud.


I have never thought of programming for reputation and honor. What I have in my heart must come out. That is the reason why I code.

Offline

#5 Before February 2015

lrussell
Member
From: Saturn's Titan
Joined: 2015-02-15
Posts: 843
Website

Re: Caps lock

Processor wrote:

Wow, time to add more useful/useless information!

I was bored and created a FormatProvider class. <3

public class ToUpperStringFormat : IFormatProvider, ICustomFormatter
{
    public object GetFormat(Type formatType)
    {
        if (formatType == typeof(ICustomFormatter)) return this;
        else return null;
    }

    public string Format(string format, object arg, IFormatProvider formatProvider)
    {
        string result = arg.ToString();
        switch (format.ToUpper())
        {
            case "U":
                return result.ToUpper();
            default:
                return result;
        }
    }
}

Now you can do:

var user = "benjaminsen"; 
var message = "hello"; 
var output = String.Format(new ToUpperStringFormat(), "[Bot] {0:U}: {1}", user, message); 
// output = [Bot] BENJAMINSEN: hello

So gud.

That is absolutely overkill for all intents and purposes and I don't recommend using that.

Offline

#6 Before February 2015

Processor
Member
Joined: 2015-02-15
Posts: 2,246

Re: Caps lock

lrussell wrote:

That is absolutely overkill for all intents and purposes and I don't recommend using that.

Agreed.


I have never thought of programming for reputation and honor. What I have in my heart must come out. That is the reason why I code.

Offline

#7 2015-02-20 09:21:20

realmaster42
Formerly marcoantonimsantos
From: ̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍
Joined: 2015-02-20
Posts: 1,380
Website

Re: Caps lock

Processor wrote:

lrussell wrote:

That is absolutely overkill for all intents and purposes and I don't recommend using that.

Agreed.

Agreed.


http://i.imgur.com/bjvgH5L.png?1

Offline

#8 2015-02-20 18:23:36

Vitalijus
Member
From: Lithuania
Joined: 2015-02-15
Posts: 1,384
Website

Re: Caps lock

marcoantonimsantos wrote:
Processor wrote:

lrussell wrote:

That is absolutely overkill for all intents and purposes and I don't recommend using that.

Agreed.

Agreed.

Free-Poster alert.


wn7I7Oa.png

Offline

Vitalijus1424453016475111

Board footer

Powered by FluxBB

[ Started around 1715001960.2215 - Generated in 0.051 seconds, 12 queries executed - Memory usage: 1.49 MiB (Peak: 1.63 MiB) ]