|
Have you thought of a for loop
Stephen Lintott Bsc IT (RAU)
|
|
|
|
|
Not sure how a for loop is going to help here as the TrimEnd method itself removes any instances of the specified char[]. Can you show me what you mean please?
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Forget about the trimEnd method and do the following.
char [] chars = YourText.ToCharArray();
for (int i=startIndex;i<chars.length;i++)>
chars[i]='\0';
Where startIndex is equal to the first character you want to remove.
Stephen Lintott Bsc IT (RAU)
|
|
|
|
|
Use the Substring method intead:
if (s.EndsWith("000000")) {
s = s.SubString(0, s.Length - 6);
} else {
' does not end with zeroes.
}
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa. How would you handle the following calculation? Just for interest sake.
I have an amount, which I can now correct get using the suggested method of SubString. I need to multiply that amount by 2.3 and then multiply the result by a further 9262.608696. Net amount I get and I do a Math.Round(netamnt, 2) to get the amount rounded to 2 decimal places. I would ideally want the netamnt without the decimal place. For example.
16436 * 2.3 * 9262.608696
The above gives me the following:
16436 * 2.3 = 37802.8
37802.8 * 9262.608696 = 350152544.0131488.
I would like to have my result as 35015254401.
What would be the best way of doing this?
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Just multiply the value by 100.0 and round to zero decimal places.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
HI ,
I am trying to impement object pooling.Where the object are remote objects.
Using this remote object i am calling a class in which i am having a method with while loop which runs for 1 min.
I found that after some time my remote object are lost.
it means if i have 10 object
Then for all the 10 object the method is called a part of the code is excuted but after that we don't know where that object goes .As at last we are updating a log file which is not getting updated so we concluded that remote object gets lost ...
Please help us on thiss...
The sample code is as
public class CallingClass : MarshalByRefObject, IBusinessComponent
{
[System.Runtime.Remoting.Messaging.OneWay()]
void IBusinessComponent.ProcessRequestOW1(Int32 hashCode,string URI)
{
CretaeLOG("Start")
ProcessRequest(hashCode);
CretaeLOG("END")
}
}
public void ProcessRequest(Int32 hashCode)
{
int dtStart = DateTime.Now.Minute;
int initialMinute = dtStart;
while (dtStart < initialMinute + 1)
{
dtStart = DateTime.Now.Minute;
}
}
Singleton class is as follow:
public sealed class ObjInstance
{
private Int32 m_Hashcode;
private string m_URI;
public Int32 Hashcode
{
get { return m_Hashcode; }
set { m_Hashcode = value; }
}
public string URI
{
get { return m_URI; }
set { m_URI = value; }
}
public PIMS.Interfaces.IBusinessComponent IBusinessObject;
}
internal sealed class PoolObject
{
private static PoolObject poolInstance = null;
private static object syncRoot = new object();
public Hashtable objectPool = new Hashtable();
Int32 maxPoolSize = 5;
public Hashtable usedObject = new Hashtable();
public Hashtable usedObjectHashCode = new Hashtable();
//Timer poolTimer = new Timer();
private PoolObject()
{
//When pool timer's timeout occures call MoveToPool function to get available objects
// poolTimer.Elapsed += new ElapsedEventHandler(MovetoPool);
//poolTimer.Tick += new EventHandler(poolTimer_Tick);
// poolTimer.Interval = 60;
// poolTimer.Start();
CreatePool();
}
public static PoolObject Instance
{
get
{
if (poolInstance == null)
{
lock (syncRoot)
{
poolInstance = new PoolObject();
}
}
return poolInstance;
}
}
public void CreatePool()
{
.... Some code here.........
}
public PIMS.Interfaces.IBusinessComponent GetObjectFromPool(string URI, ref Int32 hashCode)
{
.... Some code here.........
}
public void MovetoPool()
{
.... Some code here.........
}
}
|
|
|
|
|
Override GetLifetimeService() InitializeLifetimeService() to return an ILease object, by default it returns a lease of 5 minutes (IIRC).
[update] oops, pasted wrong method [update]
|
|
|
|
|
Falguni Joshi wrote: Objects getting lost in .Net remoting object pooling.......Plz help us its an urgent...We r facing the issue in production
You should have learnt how to use .NET Remoting before throwing it into production...
|
|
|
|
|
It's urgent! It's production dammit!
Blog link to be reinstated at a later date.
|
|
|
|
|
I dropped my boredom for a little while
|
|
|
|
|
I urgently ignored it. I find it saves me having to ignore it later.
|
|
|
|
|
Hi Everyone!
I want to use FolderBrowserDialog Component in my web application?
How can I do? In my application, that component is disable.
I want to enable that components. I try to add References>Add References>System.Windows.Forms but still disable.
Any alternative way?
Thanks in advance for your help!
|
|
|
|
|
nitar wrote: I want to use FolderBrowserDialog Component in my web application?
This is not ASP.Net Forum.
nitar wrote: I want to enable that components. I try to add References>Add References>System.Windows.Forms but still disable.
You said that yours is a Web Application, than where did you read that you can have System.Windows.Forms available.
nitar wrote: Any alternative way?
You can do it js. You'll probably have to create your own GUI for it but this will give you access to the user's file system. so via the File System Object (FSO) you create Drive, file objects etc.
heres a small sample thats in that reference i just linked.
so in theory you could load up an absolute div that has a dropdown which you populate with the users Drives that you've collected info on via the FSO.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
class A
{
public virtual void get()
{
Console.WriteLine("Hello");
}
}
class B:A
{
public override void get()
{
Console.WriteLine("Fine");
}
}
Ist Method
A e = new B();
e.get();
IInd Method
B e = new B();
e.get();
Difference between in Ist Method and IInd Method of intializing the object of the the Class A
|
|
|
|
|
The 2nd method you're not instantiating class A, you're instantiating class B
|
|
|
|
|
|
Difference between in Ist Method and IInd Method
Ist Method returns. "Hello"
IIst Method returns. "Fine"
spaps
|
|
|
|
|
|
Nope !!!!
The same output = "Fine"
|
|
|
|
|
if you do like this:
A e = new A();
e.get();
B c = new B();
c.get();
you will have Hello and Fine too..
spaps
|
|
|
|
|
yes it's correct
but if we have
A e = new B(); //Upcasting
e.get();
we will have "Fine"
|
|
|
|
|
lisan_al_ghaib wrote: A e = new B()
sorry...that's my fault
spaps
|
|
|
|
|
You'll get the same output in both cases because, even though you are using class A in the 1st method, you are instantiating an instance of class B (because B inherits from A). What you can't do here, is access methods of B that aren't in A.
|
|
|
|
|
.NET- India wrote: Ist Method
A e = new B();
e.get();
IInd Method
B e = new B();
e.get();
Difference between in Ist Method and IInd Method of intializing the object of the the Class A
The question can not be answered, as it's incorrect. Neither of the two methods creates an instance of the A class.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|