[英]Problems converting VB.NET to C#
我正在尝试将某些vb.net转换为C#,但我不断收到错误消息。 目前,我收到以下错误:
The name 'Strings' does not exist in the current context
问题行是:
strUser = Strings.LCase(Strings.Trim(strUserInitials[strUserInitials.GetUpperBound(0)])).ToString();
有人知道为什么会这样吗?
我设置了以下名称空间:
using System;
using System.Web;
using System.Web.Services;
using System.Web.Script;
using System.Web.Script.Services;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
我正在使用Web服务(asmx文件)。
Strings
实用程序类位于Microsoft.VisualBasic
命名空间中。
您可以添加对库的引用,并从C#代码中使用它,或重写调用:
strUser = strUserInitials[strUserInitials.GetUpperBound(0)].ToString().Trim().ToLower();
在c#中, System
名称空间中没有Strings
类。 并在string
ToLower
LCase
更改为ToLower
,因此:
strUser = string.ToLower(string.Trim(strUserInitials[strUserInitials.GetUpperBound(0)]));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.