|
Hi,
How to check that a textbox contain only spaces.
How to trim all the space after the string. String.Trim() only clear one space after the charecter in c#
Regards,
YPKI
|
|
|
|
|
Not true. String.Trim() will clear all leading and trailing spaces in the string.
«_Superman_»
|
|
|
|
|
ypki wrote: How to check that a textbox contain only spaces.
There are many ways, but they all end up looping through the string in some way or the other to check each character.
For example, in framework 3.5 you can use extension methods. The string implements IEnumerable<char>, so you can use the All method to enumerate the characters and check a condition for each character:
string text = " ";<br />
bool allSpaces = text.All(c => c == ' ');
ypki wrote: How to trim all the space after the string. String.Trim() only clear one space after the charecter in c#
No, it doesn't. It removes all white space characters at the beginning and at the end of the string.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
string s = "ad df d a ";
string s1= s.Replace(" ", "");
Tan Li
I Love KongFu~
|
|
|
|
|
return txtBox.Text.Trim().Length == 0;
|
|
|
|
|
hello All,
I have created a WCF Application.now i want to integrate the Logging Application Block.
i want to Log them into a txt file as well. (this is my main concern).
when doing so much googling i find out about Flatfilelistner and i configured my App.config using following Listner but it didn't work for me.
<add fileName="D:\trace.log" header="----------------------------------------"
footer="----------------------------------------" formatter="Text Formatter"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
traceOutputOptions="Callstack" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="FlatFile TraceListener" />
can any one please guide me to resolve this problem.
Amit Agarwal
|
|
|
|
|
Amit Agarrwal wrote: but it didn't work for me.
You'll have to give a little more than this. What didn't work? Did you get exceptions? Did the file not write?
only two letters away from being an asset
|
|
|
|
|
Dear All,
I want web browser dll control ..(only web control not window control)
Sir/Mam,
I'm Kannan.I Like very much for the coding for the project
THANKNG YOU
KANNAN
|
|
|
|
|
A "webbrowser"-control, for ASP.NET instead of WinForms? That doesn't exist. How would you render a browser in an HTML-page?
Isn't it (a lot!) easier to use a in your HTML?
I are troll
|
|
|
|
|
Thank u very much Eddy Vluggen
Sir/Mam,
I'm Kannan.I Like very much for the coding for the project
THANKNG YOU
KANNAN
|
|
|
|
|
dear friends pls help me in this
wats the equalent operator for
1.this pointer ->
2. scope resolution operator ::
3. pointers
4.arrays
5. matrix
6.memory allocation and free up
pls explain with example codes
|
|
|
|
|
this-> becomes this.
:: becomes .
pointers can be used with the unsafe keyword and is still *, but not recommended as garbage collection will be effected
arrays are the same [] but is written as string[] s = new string[3];
by matrix if you mean 2 dimensional arrays then they are declared as string[,]
there is also something called jagged arrays - string[][]
memory allocation is using new
free up happens through the garbage collector (automatic)
«_Superman_»
|
|
|
|
|
|
lawrenceinba wrote: 1.this pointer ->
->
(Pointers can only be used in an unsafe context.)
lawrenceinba wrote: 2. scope resolution operator ::
base.
lawrenceinba wrote: 3. pointers
References (or in some cases pointers).
lawrenceinba wrote: 4.arrays
Array objects.
lawrenceinba wrote: 5. matrix
Do you mean a two dimensional array or matrix mathematics?
lawrenceinba wrote: 6.memory allocation and free up
Create and release objects.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
thanks friend.. its very useful for me
ya two dimensional matrix
|
|
|
|
|
Hi,
if you need to understand or create C# programs, I strongly suggest you buy an introductory book on the language and work your way through it; that may take a day or two, but will provide you much more knowledge and insight than one hundred questions and answers can provide.
|
|
|
|
|
|
Hi All,
I am really confused with.....static classes...its harmful or beneficial in terms of scalability.
no. of users are accessing one static method of static class.....that performs any operation like data insertion, update, deletion and fetching from database.....
my confusion is that...while all users will be calling the same method using class directly then it will maintain the version or all users will be in Q.
or something else.... I am eager to know .....
Thanks
Dinesh Sharma
|
|
|
|
|
I don't really understand your question, but I'll try to shed some light.
If you are building a multi-threaded application (like an ASP.NET web application), then each thread needs to have it's own connection object when working with the database. If you are trying to use the same connections for all threads, only one thread at a time can access the database, and that would indeed be harmful for the scalability.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
static classes can only contain static members.
These classes cannot be instantiated using new and are automatically loaded by the runtime.
If the static methods refers to static variables they are not thread safe.
«_Superman_»
|
|
|
|
|
DineshSharmain wrote: no. of users are accessing one static method of static class.....that performs any operation like data insertion, update, deletion and fetching from database.....
There is no harm in using it when the static method is not using any shared variables. See the following code
public static class Foo
{
public static void FooMethod(string a,string b){
....
}
} In the above example, FooMethod is safe as it is not using any shared objects. Whenever you use FooMethod , you will have separate copy of variable a and b .
public static class Foo
{
private static string FooVariable = "";
public static void FooMethod(){
}
} Above given code is not safe as static variable(FooVariable) is shared across multiple threads. Read about thread synchronization techniques.
|
|
|
|
|
Thanks for your reply.....
my problem is not related to database....its related to performance & scalability of static classes.
code is as follows -
static public class TempExample
{
static public bool GetCombo(object a, out DataSet dsAccountClass, string strClassType)
{
IDBHelper intfDBHelper = DBClient.GetDBHelper();
dsAccountClass = new DataSet();
IDataParameter[] arParms = intfDBHelper.CreateDBParamsArray(2);
arParms[0] = intfDBHelper.CreateNewDBParam("ID", SqlDbType.NVarChar, 6);
arParms[0].Value = a.strA;
arParms[1] = intfDBHelper.CreateNewDBParam("ClasificationType", SqlDbType.NVarChar, 1);
arParms[1].Value = strClassType;
try
{
using (IDbConnection connection = DBClient.GetConnection(a.strSystem))
{
intfDBHelper.FillDataset(connection, CommandType.StoredProcedure, "p_GetSpConditionCalssCombo", dsAccountClass, new string[] { "dt_ProductClassID" }, arParms);
}
if (dsAccountClass.Tables[0].Rows.Count == 0)
return false;
return true;
}
catch (Exception ex)
{
throw DBClientUtils.GetDBErrorMessages(ex, a.strUser);
}
finally
{
dsAccountClass.Dispose();
}
}
}
Multiple user will be accessing this class without creating an object so what will happen if 100 users are trying to access the same method of class at the same time.
Dinesh Sharma
|
|
|
|
|
DineshSharmain wrote: its related to performance & scalability of static classes.
Static classes will be invoked when any of the members are accessed for the first time and it will be available in memory until the application domain unloads.
DineshSharmain wrote: if 100 users are trying to access the same method of class at the same time
Nothing will happen. I reiterate, if your method is using another static variables, then you need synchronization mechanisms to ensure one thread will modify it at a time. If it is not using any static variables, your method is safe.
|
|
|
|
|
Thanks Navneet
wat about the code....I have given....is this thread safe
may i get any deadlock situation in my application due to this ...as m getting if load increase on application so m digging all this.
Dinesh Sharma
modified on Wednesday, January 7, 2009 2:52 AM
|
|
|
|
|
I don't know what is methods DBClient.GetDBHelper() and intfDBHelper.CreateDBParamsArray(2) doing and where dsAccountClass variable is declared. Other than that, I think it is safe.
|
|
|
|