小编kar*_*k k的帖子

将字符串从小写转换为大写,并使用C#从字符串中删除特殊字符

我正在开发一个带有用户ID的登录表单.我希望用户以指定的格式创建用户标识.我需要一个使用C#将所有小写字母转换为大写的方法.用户标识将位于以下fomat中.格式为:

xyz\t4z4567(字符不区分大小写)

规则:

1.创建用户名时只允许使用特殊字符\.2. UserID sholud被转换为大写.like(xyz - > XYZ)我需要检查用户在创建用户标识时是否输入任何特殊字符.如果UserID中存在任何特殊字符,则方法needshold删除特殊字符,并将所有小写字母转换为大写字母.

最后结果应该是以下方式:

xyz\t4z45 @ 67 ---> XYZ\T4Z4567

我使用以下方法检查字符串是否包含以下字符,如果是,我将替换为空.

public string RemoveSpecialChars(string str)
{
   string[] chars = new string[] { ",", ".", "/", "!", "@", "#", "$", "%", "^", "&", "*", "'", ";", "-", "_", "(", ")", ":", "|", "[", "]" };

    for (int i = 0; i < chars.Length; i++)
    {
        if (str.Contains(chars[i]))
        {
            str = str.Replace(chars[i], "");
        }
    }

    return str;
}
Run Code Online (Sandbox Code Playgroud)

c# uppercase

2
推荐指数
1
解决办法
9286
查看次数

获取xml文件中标记之间的数据

我想获取以下XML中的<lat><lng>标记之间的数据:

<viewport>
 <southwest>
  <lat>41.7450495</lat>
  <lng>-87.8859170</lng>
 </southwest>
</viewport>
Run Code Online (Sandbox Code Playgroud)

这是更大的XML的一部分:

<?xml version="1.0" encoding="UTF-8"?>
<GeocodeResponse>
 <status>OK</status>
 <result>
  <type>locality</type>
  <type>political</type>
  <formatted_address>Chicago, IL, USA</formatted_address>
  <address_component>
   <long_name>Chicago</long_name>
   <short_name>Chicago</short_name>
   <type>locality</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>Cook</long_name>
   <short_name>Cook</short_name>
   <type>administrative_area_level_2</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>Illinois</long_name>
   <short_name>IL</short_name>
   <type>administrative_area_level_1</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>United States</long_name>
   <short_name>US</short_name>
   <type>country</type>
   <type>political</type>
  </address_component>
  <geometry>
   <location>
    <lat>41.8781136</lat>
    <lng>-87.6297982</lng>
   </location>
   <location_type>APPROXIMATE</location_type>
   <viewport>
    <southwest>
     <lat>41.7450495</lat>
     <lng>-87.8859170</lng>
    </southwest>
    <northeast>
     <lat>42.0109012</lat>
     <lng>-87.3736794</lng>
    </northeast>
   </viewport>
   <bounds>
    <southwest>
     <lat>41.6443350</lat>
     <lng>-87.9402669</lng>
    </southwest>
    <northeast>
     <lat>42.0231310</lat>
     <lng>-87.5236609</lng>
    </northeast>
   </bounds>
  </geometry>
 </result>
</GeocodeResponse>
Run Code Online (Sandbox Code Playgroud)

现在,我正在尝试使用此代码来解析它:

string url …
Run Code Online (Sandbox Code Playgroud)

c# xml xml-parsing

2
推荐指数
1
解决办法
3663
查看次数

使用C#以编程方式取消gridview行编辑模式

我正在使用可编辑的GridView.在单击行的编辑按钮时,该行将进入可编辑模式,一旦我更新当前行的详细信息,该行将被保存并进入正常模式.

在这里,我面临一个问题.当我将行设置为可编辑模式时,单击一个按钮(不是网格的一部分)我想将可编辑行模式带到正常模式.

c# gridview buttonclick

2
推荐指数
2
解决办法
2万
查看次数

如何更改devexpressgrid中所选行的颜色

我是DevExpress网格的新手.我需要在选择行时更改网格中行的颜色.

有人可以发一些代码来实现上述场景..

提前致谢..

wpf grid devexpress

1
推荐指数
1
解决办法
1万
查看次数

如何从googleapis考虑位置的纬度和经度

我使用"http://maps.googleapis.com/maps/api/geocode/xml?address="+address+"&sensor=true"来获取某个位置的纬度和经度.从这个我得到如下响应:

<?xml version="1.0" encoding="UTF-8"?>
<GeocodeResponse>
 <status>OK</status>
 <result>
  <type>locality</type>
  <type>political</type>
  <formatted_address>Chicago, IL, USA</formatted_address>
  <address_component>
   <long_name>Chicago</long_name>
   <short_name>Chicago</short_name>
   <type>locality</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>Cook</long_name>
   <short_name>Cook</short_name>
   <type>administrative_area_level_2</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>Illinois</long_name>
   <short_name>IL</short_name>
   <type>administrative_area_level_1</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>United States</long_name>
   <short_name>US</short_name>
   <type>country</type>
   <type>political</type>
  </address_component>
  <geometry>
   <location>
    <lat>41.8781136</lat>
    <lng>-87.6297982</lng>
   </location>
   <location_type>APPROXIMATE</location_type>
   <viewport>
    <southwest>
     <lat>41.7450495</lat>
     <lng>-87.8859170</lng>
    </southwest>
    <northeast>
     <lat>42.0109012</lat>
     <lng>-87.3736794</lng>
    </northeast>
   </viewport>
   <bounds>
    <southwest>
     <lat>41.6443350</lat>
     <lng>-87.9402669</lng>
    </southwest>
    <northeast>
     <lat>42.0231310</lat>
     <lng>-87.5236609</lng>
    </northeast>
   </bounds>
  </geometry>
 </result>
</GeocodeResponse>
Run Code Online (Sandbox Code Playgroud)

响应具有许多位置的lng和lat值.那么我要考虑哪一个?

google-maps latitude-longitude weather-api google-maps-api-3 google-weather-api

0
推荐指数
1
解决办法
638
查看次数