小编Riz*_*hid的帖子

使用c#删除数组中的空白值

有没有任何方法可以从数组中删除空索引,例如

string[] test={"1","","2","","3"};
Run Code Online (Sandbox Code Playgroud)

在这种情况下有任何metod可用于从数组中使用c#删除空白索引我希望得到这种格式的数组,这 test={"1","2","3"};意味着从数组中删除两个索引并最终得到3个索引我没有得到确切的代码数组这是我想做的提示

c#

67
推荐指数
3
解决办法
11万
查看次数

window.location和location.href之间的区别

我很困惑,之间的差异window.locationlocation.href.两者似乎都以同样的方式行事.

有什么不同?

javascript

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

15
推荐指数
5
解决办法
4万
查看次数

使用VBScript查找毫秒的时间

我希望得到毫秒的时间目前使用Timer()方法,但它只提供访问最多任何想法?

请确保我不想将秒转换为毫秒,希望得到毫秒

vbscript

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

在.NET中获取日期和时间

目前我正在尝试使用此代码获取时间和分钟:

DateTime currentDate = DateTime.Now.Date;
int currentHour = DateTime.Now.Date.Hour;
int currentMin = DateTime.Now.Date.Minute;
Run Code Online (Sandbox Code Playgroud)

但是我得到零而不是当前的时间和分钟.我该如何解决这个问题?

.net datetime

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

将文本编写器分配给内存编写器

我正在写一个xml文件但是缺少特定字段的某些值.我检查当对象到来时包含特定值存在的值,但写入后xml该值不存在.

这是我使用的代码,我认为XmlTextWriter可能是错误的原因xml.

还有另一种方法可以用于它,TextWriter但它无法转换为内存流.

string xmlString = null;
MemoryStream memoryStream = new MemoryStream();
XmlSerializer xs = new XmlSerializer(typeof(T));
// XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.ASCII);
TextWriter xmlTextWriter=new StreamWriter(memoryStream,Encoding.ASCII);
xs.Serialize(xmlTextWriter, obj);
memoryStream =(MemoryStream)xmlTextWriter.    
//(MemoryStream)xmlTextWriter.BaseStream;
xmlString = ASCIIByteArrayToString(memoryStream.ToArray()); 
return `xmlString;`
Run Code Online (Sandbox Code Playgroud)

知道我怎么知道问题发生的原因和地点.

c# asp.net asp.net-mvc c#-3.0 c#-4.0

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

使用VB脚本运行窗口媒体播放器或VLC

我想使用.vbs文件运行窗口媒体播放器,目前我正在运行这样的应用程序

Set objWord = CreateObject("Word.Application")
objWord.Visible = True

Set objWord = CreateObject("Excel.Application")
objWord.Visible = True
Run Code Online (Sandbox Code Playgroud)

但没有办法运行窗口媒体播放器,也想在媒体播放器中播放示例文件

vbscript powershell

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

从列表中获取相同元素的总和

我希望使用泛型来从列表中得到总和

List<Name,Value> test=new List<Name,Value>();
E.g list contain these element
test.Add(One,5);
test.Add(Second,5);
test.Add(Third,5);
test.Add(One,5);
test.Add(One,5);
test.Add(Second,5);
Run Code Online (Sandbox Code Playgroud)

最后想要得到像元素一样的值,其中一个名称包含值15元素,第二个名称包含值10元素,第三个名称包含值5

我不想手动迭代每个元素.这不是一个确切的语法,它是一个想法.

c# c#-3.0 c#-4.0

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

在C#中获取用户登录名

如何在C#中从系统检查登录用户名我尝试使用此方法

static string whoisLoggedIn(string HostOrIP)
{
     GUFlag = true;
     HostOrIP = Environment.MachineName;
     System.Management.ConnectionOptions myConnectionOptions = new System.Management.ConnectionOptions();
     myConnectionOptions.Impersonation = System.Management.ImpersonationLevel.Impersonate;

     System.Management.ManagementScope objwmiservice;
     System.Management.ManagementObjectSearcher myObjectSearcher2;
     System.Management.ManagementObjectCollection myCollection2;

     try
     {
         objwmiservice = new System.Management.ManagementScope(("\\\\" + (HostOrIP +
"\\root\\cimv2")), myConnectionOptions);
         objwmiservice.Connect();
         myObjectSearcher2 = new System.Management.ManagementObjectSearcher(objwmiservice.Path.ToString(),
"Select UserName from Win32_ComputerSystem");
         myObjectSearcher2.Options.Timeout = new TimeSpan(0, 0, 0, 0, 7000);
         myCollection2 = myObjectSearcher2.Get();
         GUFlag = false;

         foreach (System.Management.ManagementObject myObject in myCollection2)
         {
             if (!(myObject.GetPropertyValue("Username") == null))
             {
                 string Userx = myObject.GetPropertyValue("Username").ToString();
                 int posx = Userx.LastIndexOf("\\");
                 if …
Run Code Online (Sandbox Code Playgroud)

c# asp.net c#-3.0 c#-4.0

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