从java转换为C# [英] Convert from java to C#

查看:329
本文介绍了从java转换为C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计我想要你的帮助,所以java有Enumeration类,更具体地说它有一个布尔方法是允许你检查Enumeration是否包含元素的类。





Hey guys I want your help, so java has the Enumeration class and more specifically it has a boolean method is the class that allows you to check if the Enumeration contains element.


public String extractSelectAllValue(Hashtable pDataTable) {
Enumeration lKeyEnumeration;
String lKeyValue;
String lDataValue;
lKeyValue = "";
lDataValue = "";
try {
	lKeyEnumeration = pDataTable.keys();
	while(lKeyEnumeration.hasMoreElements()) {
	lKeyValue = (String)lKeyEnumeration.nextElement();
	lDataValue =  lDataValue +(String)pDataTable.get(lKeyValue) + "::";
    }
	return lDataValue;
    } catch(Exception e) {
      System.out.println("Error Extracting all Values of the list");
      e.printStackTrace();
      return "";
    }
	}





你明白了,我想知道c#是否有这样的东西。因为我已经检查了Enum类,但我找不到任何反映它的方法。



感谢您的帮助。



you get the idea, I wanted to know if c# has something like that. Because I have already checked the Enum class and I did not find any method that mirrors that.

Thanks for your help.

推荐答案

如果您正在使用 Hashtable s,则可以执行以下操作:

If your are using Hashtables the in c# you can do this :
Hashtable hashtable = new Hashtable();
foreach (var key in hashtable.Keys)
{
    object o = hashtable[key]; // value of the key
    // do your stuff here
}


C#还包含Enumaration class.Please看看下面的代码。

C# also contains the Enumaration class.Please check out the below code.
using System;
using System.Collections;

public virtual string extractSelectAllValue(Hashtable pDataTable)
{
System.Collections.IEnumerator lKeyEnumeration;
string lKeyValue;
string lDataValue;
lKeyValue = "";
lDataValue = "";
try
{
    lKeyEnumeration = pDataTable.Keys.GetEnumerator();
    while (lKeyEnumeration.hasMoreElements())
    {
    lKeyValue = (string)lKeyEnumeration.nextElement();
    lDataValue = lDataValue + (string)pDataTable[lKeyValue] + "::";
    }
    return lDataValue;
}
catch(Exception ex)
{
throw ex;
}


这篇关于从java转换为C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆