473,399 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

how can i turn this java method to c#

public String generateSP()
{
String s = "";
Iterator iterator = hmTable.keySet().iterator();
String s1 = "";
while(iterator.hasNext())
{
String s2 = (String)iterator.next();
s = s.length() != 0 ? s + "," + s2 : s2;
}
return s;
}
thx!

Jan 4 '06 #1
5 1297
The var s1 appears never used?
C#:
public String generateSP()
{
String s = null;
foreach (String s2 in hmTable.Keys)
{
s = (s != null) ? (s + "," + s2) : s2;
}
return s;
}

Due to some error, I have to post twice. Sorry if it this reply appears
twice.

Regards,
Thi

Jan 4 '06 #2
Thx Truong Hong Thi

another ques.
dose c# has some type like java type Vector (java.util.Vector)
?

:)

Jan 4 '06 #3
C# System.Collections.ArrayList provide similar functions, but is is
not thread-safe by default. To have thread-safe array list like
java.util.Vector, use ArrayList.Synchronized method:

ArrayList theVector = ArrayList.Synchronized(new ArrayList);

Hope that helps,
Thi

Jan 4 '06 #4
Truong Hong Thi wrote:
C# System.Collections.ArrayList provide similar functions, but is is
not thread-safe by default. To have thread-safe array list like
java.util.Vector, use ArrayList.Synchronized method:

ArrayList theVector = ArrayList.Synchronized(new ArrayList);


However, that model of thread-safety is pretty shallow anyway - you
can't safely iterate through a synchronized ArrayList (or Vector in
Java) without locking for the whole loop rather than just each bit of
the loop.

Personally I usually avoid the synchronized wrappers, explicitly
locking the SyncRoot property (or a private lock) if a collection needs
to be shared between threads.

Jon

Jan 4 '06 #5
thx Jon Skeet and Truong Hong Thi

:)

Jan 5 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
0
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what...
0
by: mailkhurana | last post by:
Hii , I am trying to use a type 2 driver to connect to DB2 0n AIX 5 I have a small java test to class to establish a conneciton with the db .. I am NOT using WAS or any appserver When I try to...
12
by: Mark Fink | last post by:
I wrote a Jython class that inherits from a Java class and (thats the plan) overrides one method. Everything should stay the same. If I run this nothing happens whereas if I run the Java class it...
18
by: jacksu | last post by:
I have a simple program to run xpath with xerces 1_2_7 XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); XPathExpression xp = xPath.compile(strXpr);...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
5
by: r035198x | last post by:
Setting up. Getting started To get started with java, one must download and install a version of Sun's JDK (Java Development Kit). The newest release at the time of writting this article is...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.