|
I am using a dropdown list. I have tried the FindByValue and it isn't helping either
J9
|
|
|
|
|
Hi,
How can I retreive RAM size of my computer through c# program.
Thanks in Advance
Phanindra...
|
|
|
|
|
Hi,
I use P/Invoke and call GlobalMemoryStatus() from kernel32.dll to get that.
It returns a struct, the dwTotalPhys field is what you want.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/AllLanguages/General
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
|
The GlobalMemoryStatus function retrieves information about current available memory. The function returns information about both physical and virtual memory. This function supersedes the GetFreeSpace function.
P.S. For these kind of function u can use API-Guide a good software
|
|
|
|
|
How can I check whether the file is ReadOnly or not.
Saqib
|
|
|
|
|
Use FileInfo class and check FileInfoObject.Attributes . This will return FileAttributes enum. You can find out Readonly inside this
|
|
|
|
|
string FilePath = @"C:\TEST.txt";
System.IO.FileInfo Info = new System.IO.FileInfo(FilePath);
if (Info.IsReadOnly)
{
Console.WriteLine("FILE IS READ-ONLY");
}
|
|
|
|
|
according to me
internal Access is limited to the current assembly.
protected internal Access is limited to the current assembly or types derived from the containing class.
but i am ot being able to implement it in the programs.
somebody please provide any example that elaborates how to use these things.
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
Sonia Gupta wrote: internal Access is limited to the current assembly.
Correct
Sonia Gupta wrote: somebody please provide any example that elaborates how to use these things.
Assume you have two class file, class1 and class2. Your class1 looks like
internal class class1
{
}
class2 looks like
class class2
{
public class2()
{
class1 c1 = new class1();
}
}
This is how internal works. You won't be able to get reference to internal class from other assembly. Try making the internal to public to get access.
Sonia Gupta wrote: protected internal Access is limited to the current assembly or types derived from the containing class.
Protected keyword is mostly used in internal classes ( class inside other one ). It can be accessed by containing type and any type that inherits containing type. So protected internal would be protected level + internal level. I am not sure regarding this, check with online documentations.
|
|
|
|
|
N a v a n e e t h wrote: class class2{ public class2() { class1 c1 = new class1(); //Will produce error }}
will produce an error at runtime or at design time.
i tried it, neighter it created error at runtime nor at compile time
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
Sonia Gupta wrote: i tried it, neighter it created error at runtime nor at compile time
Make sure classes are in different assembly. When you compile you will get is inaccessible due to its protection level
|
|
|
|
|
Hi
Protected is like a private member for a class, but it's visible in derived classes also.
internal is like public but only inside the current assembly.
so.
if you need a property that can be accessed from other classes inside your assembly and a derived class from another assembly should be able to provide a value for it, you make it
protected internal, which means public inside the current assembly and private for all the other asemblies.
let's say you have 2 assemblies the BaseClassLib and the ConsumerLib
now in the BaseClassLib you have 2 classes called ConsumerClass and ProviderClass
<br />
public class ConsumerClass<br />
{<br />
public ConsumerClass(ProviderClass Provider)<br />
{<br />
Console.WriteLine(Provider.getProtIntVal());<br />
}<br />
}<br />
public abstract class ProviderClass<br />
{<br />
protected internal abstract string getProtIntVal();<br />
}<br />
in the ConsumerLib you have a Reference to the ProviderLib and you have 2 classes called StartupClass and DerivedProviderClass
<br />
public class DerivedProviderClass:ProviderClass<br />
{<br />
public DerivedProviderClass()<br />
{<br />
}<br />
protected override string getProtIntVal()<br />
{<br />
return "this is a string";<br />
}<br />
}<br />
public class StartupClass<br />
{<br />
[STAThread]<br />
public static void Main(params string[] args)<br />
{<br />
DerivedProviderClass c = new DerivedProviderClass();<br />
console.WriteLine(c.getProtIntVal());<br />
ConsumerClass cons = new ConsumerClass(c);<br />
}<br />
}<br />
hope this helps
greets
m@u
|
|
|
|
|
Create these classes inside a ClassLibrary
<br />
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
<br />
namespace InternalAssembly<br />
{<br />
public class BasicTaskClass<br />
{<br />
string str=null;<br />
<br />
<br />
protected virtual void DoTask()<br />
{<br />
return;<br />
}<br />
<br />
internal void DoJob()<br />
{<br />
this.DoTask();<br />
}<br />
<br />
protected internal string Data<br />
{<br />
get<br />
{<br />
return this.str;<br />
}<br />
set<br />
{<br />
this.str = value;<br />
}<br />
}<br />
<br />
}<br />
<br />
<br />
public sealed class DoTaskClass<br />
{<br />
public string Go(string str, BasicTaskClass tsk)<br />
{<br />
tsk.Data = str;<br />
tsk.DoJob();<br />
return tsk.Data;<br />
}<br />
<br />
}<br />
<br />
}<br />
and create these in the ConsoleApplication and then add ClassLibrary you made before as a reference
</code>
using System;
using System.Collections.Generic;
using System.Text;
namespace InternalProtectedDemo
{
class UpperCaseTask:InternalAssembly.BasicTaskClass
{
protected override void DoTask()
{
this.Data=this.Data.ToUpper();
}
}
class Program
{
static void Main(string[] args)
{
InternalAssembly.DoTaskClass doTaskClass = new InternalAssembly.DoTaskClass();
InternalAssembly.BasicTaskClass basicTask = new InternalAssembly.BasicTaskClass();
basicTask.DoJob();
Console.WriteLine(doTaskClass.Go("hello", new InternalAssembly.BasicTaskClass()));
Console.WriteLine(doTaskClass.Go("hello", new UpperCaseTask()));
Console.ReadKey();
}
}
}
</code>
as you can see you cannot access to Data properties or DoTask method
without deriving from the BasicTaskClass in other assemblies.
and you can't access to DoJob method even with derivation.
these going to be very useful in large applications or expandable ones and this example is not showing this!!!
sorry nothing better than this crossed my mind
|
|
|
|
|
Sonia - I answered this question for you before. Did you not understand it then?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
sir no, it iw being very complicated .
please explain it again. with an example
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
When I answered you last time, I posted an example. Please refer back to it.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
If your having trouble with this I'd suggest you go right back to the start, buy a book on the basics of C# and start learning from the begining.
|
|
|
|
|
Hello,
i have a program which i need to control it's GUI, so i will be able to take over the form of the program and can write code which will get me the abillity to press buttons.
Any ideas?
Thank you
|
|
|
|
|
there is some APIs which can lock keyboard/Mouse and simulate keyPress/MouseClick/MouseMove and find the Window name,position and size
but first I think you must create a map of your gui interface (like where is the button and...) and then do what you want sequentially using the APIs but before that you must lock the keyboard for preventing user interrupts.
just do some searches in codeproject and MSDN for APIs you will found them easily.
good luck
|
|
|
|
|
I want to find dynamically that child element of one xml has the attribute or not?
1.
<property id="220" name="Stage 1 Temp." prgbar="false" selected="false" min="0" max="40" pwd="true" units="C" gauge="true" amberthresholdval="30" redthresholdval="35" amberwarning="Stage 1 Temp is near upper limit." redwarning="Stage 1 Temp has exceeded upper limit."/>
2.
<property id="202" name="Max. Input Air Temp." prgbar="true" selected="true" min="0" max="100" pwd="true" units="C" gauge="false"/>
this two properties are the same child elements of the xml but have different attributes so i want to know dynamically that the property has the attribute and it's value or not dynamically in c#.net windows application
please help me on this
Thanks in advance
PraveenKumar Palla
|
|
|
|
|
Hi.
I am using DataAdapter to retrieve some values in a database.
Normally, the DataSet which the DataAdapter fills will have one table and all the rows is there.
Is it possible that depending on the values fetched by the query operations, the rows are spread across multiple tables in the DataSet.
Here's an example:
ID Name Age Gender
--------------------------------------------------
1 Andrew 29 M
2 Paul 12 M
3 Mary 25 F
4 James 35 M
5 Heather 17 F
I would like to retrieve all these rows from the DB using DataAdapter.Fill() method, BUT the DataSet which will be filled should have two tables: one with the guys and one with the girls.
Any suggestions?
Thanks.
|
|
|
|
|
Call the Fill method twice using different SELECT statements and different DataTables .
|
|
|
|
|
I presume that you are using stored procedure. Write two select statements in stored procedure. This will return two datatables to dataset. Your stored procedure would look like this
SELECT * FROM yourtable WHERE Gender = 'M'
SELECT * FROM yourtable WHERE Gender = 'F'
When you fill this, you will get two tables in dataset with male and female details.
|
|
|
|
|
Write two different select statements.
|
|
|
|