|
I wrote an article for CP in IEnumerator and IEnumerable.Please go through that article, You will get a clear picture that what you need to do.
Sreejith Nair
[ My Articles ]
|
|
|
|
|
I’m not entirely sure what your trying to do but if you want to see the contents of an ArrayList for example the code would be something like this. (I’m not compiling this so it may have a syntax error or two but you'll get the idea)
ArrayList ai = new ArrayList();
ai.add(“Hello”);
ai.add(“world”);
IEnumerator _E = ai.GetEnumerator();
while(_E.MoveNext())
{
Console.writline(_E.current.ToString());
}
MSDN link is really good help too http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemiotextreaderclassreadblocktopic.asp[^]
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
|
|
|
|
|
In WebService, The WebMethod run normally, and return data success.But When WebApplication run the WebMethod, Error has "There is an error in XML document (421, 39)". may it what cause? How to do it?
|
|
|
|
|
your problem is simple : you have an error (bug) on the web server (an uncaught exception maybe)
maybe the application doesn't call the webmethod you think...
try debugging your web application from begin to end and find out where the exception ocurs and how to avoid it
I hope you understand...
By the way... visit http://nehe.gamedev.net[^]
|
|
|
|
|
Given an int variable k that has already been declared , use a while loop to print a single line consisting of 97 asterisks. Use no variables other than k .
or this....
Given an int variable n that has already been declared and initialized to a positive value , and another int variable j that has already been declared , use a while loop to print a single line consisting of n asterisks. Thus if n contains 5, five asterisks will be printed. Use no variables other than n and j .
Any ideas. I have lots of questions like this. I just need help with one of them so I can work with the rest!
Thanks in advance.
|
|
|
|
|
First, welcome as a new member to CP. This would be better to be asked in the Visual C++[^] forum since you are asking for C code. This forum is for C# questions.
Steve Maier, MCSD MCAD
|
|
|
|
|
Thanks... I am moving it over.
|
|
|
|
|
Logic is same whether it is c or C#. here i am writing example using C#. Try to use correct syntax in c for printing and reciving variable in c while using this logic.
using System;
namespace ConsoleApplication1
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
int n=5;
for(int i=0;i < n;i++)
{
Console.Write(" *");
} Console.Write("\n");
}
}
}
Sreejith Nair
[ My Articles ]
|
|
|
|
|
Do we have to smack you? Make suggstions and point her in the right direction! Don't write the code for her! How is she going to learn anything if your doing her work for her?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi all
I realise this is probably the most basic C# question I could ask, so apologies in advance, but I have searched everywhere and just can't seem to find a complete answer, all in one place.
I have a class called Donor. Inside Donor, I have properties such as Name, Address, Telephone, etc, but I would also like a collection of Donation classes.
The Donation class has properties such as Date, Amount, MethodOfPayment, etc.
So, I have a Donor class and a Donation class. And I would like my Donor class to contain a collection of Donation classes, which can be added to, removed from, and iterated around using foreach.
Could someone show me the basic steps I need to go through in order to achieve this, or point me in the direction of a good example that encompasses this problem.
Many thanks
M
|
|
|
|
|
isittheweekendyet wrote:
Could someone show me the basic steps I need to go through in order to achieve this, or point me in the direction of a good example that encompasses this problem.
You might consider having you Donation class inherit from CollectionBase which is an abstract base class for a strongly typed collection. There is a perfect example on MSDN located here[^]. If you have further questions please feel free to ask.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Here you are trying to create collection of your own type. That is cool. But before starting this, Please go through this article, which discuss clearly about custom collection and iteration. I recommand you to read this for better understanding of custom collection.
Handling Custom Collection
Sreejith Nair
[ My Articles ]
|
|
|
|
|
Hi all, I am trying to pass a function name as a parameter and use it to create an OracleDataReader:
<br />
private void DataHandler(string type, string function)<br />
{<br />
AuthViewsLookup myLookup = new AuthViewsLookup(m_AppParam);<br />
<br />
OracleDataReader rdr = myLookup.function;<br />
<br />
while(rdr.Read())<br />
{<br />
}<br />
<br />
rdr.Close();<br />
}<br />
setting the reader to myLookup.function does not work, b/c it wants the actual function name. How can I make this work? Thanks for any help.
|
|
|
|
|
|
That's not exactly what I meant. I want to tell it what function to go to by passing in the function's name.
|
|
|
|
|
I’m a fairly new programmer (was taught C++ over a two year program NAIT) and very new to C# and I was hoping someone can explain to me why string doesn’t have a constructor that accepts a string? To me the following line of code seems intuitively correct but it doesn’t work.
string s = new string(“dog”);
or
string s = new string();
s=”dog”
There must be a reason that the above doesn’t work (other than making me angry.)
The closest I can come to doing the above is
string s = “dog”;
or
string s = “\0”;
And that works but I’d like s to be DMAed.
Admittedly, my understanding of DMA with managed code is week at best. That may be the problem. Any explanations will be helpful.
Thank you,
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
12029 45 Street N.W.
Edmonton, Alberta, Canada T5W 2T7
Res. Ph: (780) 695.5589
Email: rhahn82@telus.net
|
|
|
|
|
I'm not entirely sure why this really matters to you, however if you look through the documentation you will see there are a series of different parameters that the String class can take as a parameter for its constructor. You could do the following (if you wanted that is):
string s = new string("Hello".ToCharArray());
The string class is a reference type, so remember it's important to check for a null value, but otherwise just use the assignment operator, which is how the majority of people tend to use it.
string s = "Hello";
- Nick Parker My Blog | My Articles
|
|
|
|
|
So because it’s a reference type trying to put it on the heap is redundant? Why doesn’t anyone do this:
string s = new string("Hello".ToCharArray());
?
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
|
|
|
|
|
HahnTech wrote:
So because it’s a reference type trying to put it on the heap is redundant?
No, your missing the point, I am just not sure I understand why you are hung up on the design of the class? Like I said, what I showed you is simply something you could do, however unlikely.
- Nick Parker My Blog | My Articles
|
|
|
|
|
I am so frustrating to make list in propertygrid by using arraylist. I am well-aware about other articles about this, but I cant get it working. Do I have to use PropertyDescriptorCollection or ICollection? I am not sure bec I dont know which is best to use for building list in propertygrid by arraylist.
I want nodes to look like this:
For example:
-Category
-List 1
Color
Length
....
+List 2
Color
Length
....
+List 3
....
|
|
|
|
|
If you want your collection of properties "rolled-out" (i.e., no "..." button) in the PropertyGrid then your object will need to implement ICustomTypeDescriptor and override the two GetProperties methods. For everything else, just return TypeDescriptor.AppropriateMethod with noCustomTypeDesc parameter set to true (so that it doesn't recursively call your ICustomTypeDescriptor method).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I am little confusing about override the two GetProperties methods. Can you give me more specifics about that? I was curious about TypeDescriptor.AppropriateMethod method so I looked at MSDN library and it was not there. How did you find its method?
|
|
|
|
|
Notice how AppropriateMethod was italicized/emphasized? That means it's not actually what you look up. It would've been logical for you to lookup the TypeDescriptor class even if I did mispell a method or property name and look at it's class documentation. For example, look up TypeDescriptor in the .NET Framework SDK documentation and you'll see the GetProperties overloaded methods.
When you implement the ICustomTypeDescriptor you simply define the two overloaded GetProperties methods as you would with any other interface members. If you're confused about how to implement interfaces, then I suggest you first read the C# Language Specification[^], specifically about Interfaces[^].
For example:
public class MyClass : ICustomTypeDescriptor
{
public TypeConverter GetConverter()
{
return TypeDescriptor.GetConverter(this, true);
}
public PropertyDescriptorCollection GetProperties()
{
return GetProperties(null);
}
public PropertyDescriptorCollection GetProperties(Attribute[] filter)
{
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks for telling about this:read the C# Language Specification[^], specifically about Interfaces[^]. and it helped me alot but it didnt help me with my current problem. I did what I still trying to get any results from PropertyDescriptorCollection in propertygrid, but all I got is blank. I followed your suggestions and I got it all in collection from arrays.
public class CMainForm : System.Windows.Forms.Form
{
public void ShowPropertyGrid()//init. propertygrid with datas and objects
{
ArrayList arrayList = .....///stored the arraylist from other class
foreach(ILogical pILogical in arrayList
{
string[] strHeaderArray = null;
((IEVHeaderItem)pILogical).GetHeaderDetails(out strHeaderArray);
SubListInfo.Lists.List = "List" + nCount;);///List1, List2, List3,....
SubListInfo.Lists.Type = pILogical.Type;
for(int i=0; i < strHeaderArray.Length; i++)
{
string strValue;
((IEVHeaderItem)pILogical).GetDetailColumn(i, out strValue);
if(i == 3)
ListInfo.Lists.Color = strValue;
........
}
}
}
}
[TypeConverter(typeof(SurfaceConverter))]
public class SubListInfo : SubListData
{
private int m_nID = 0;
private string m_strColor = "";
.......
public SubListInfo()
{
}
[ReadOnly(true)]
public string Color
{
get { return m_strColor; }
set { m_strColor = value; }
}
..........
}
public class SubListData
{
private string m_strList = "";
......
public SubListData() {}
[Browsable(false)]
public string List
{
get { return m_strList; }
set { m_strList = value; }
}
....
}
public class CListInfo : ICustomTypeDescriptor
{
private ArrayList m_arrayList;
#region ICUSTOMTYPEDESCRIPTOR
public String GetClassName()
{
return TypeDescriptor.GetClassName(this,true);
}
... I followed those rest of them like you said from previous message.
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public PropertyDescriptorCollection GetProperties()
{ return GetProperties(null); }
[TypeConverter(typeof(ListConverter))]
public PropertyDescriptorCollection GetProperties()
{
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
for(int i = 0; i < m_data.Count; i++)
{
SurfaceCollectionDesc pd = new SurfaceCollectionDesc(m_data,i);
pds.Add(pd);
}
return pds;
}
#endregion
}
internal class ListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType )
{
if( destType == typeof(string) && value is SurfaceInfo )
{
ListInfo emp = (ListInfo)value;
return emp.List;///List1, List2, List3,....
}
return base.ConvertTo(context,culture,value,destType);
}
}
I tried to used those codes(below) if its collection(there is three lists for now) is working or not. so it showed only last List(List3) and it didnt displayed first two lists.
[TypeConverter(typeof(ListConverter))]//,CategoryAttribute("Lists")]
public SubListInfo Lists
{
get
{
return subLists;
}
}//////it showed only last List(List3)
Did I miss something important about PropertyDescriptorCollection or TypeConverter
that displays whole lists? I may overlooking something that I alway do that.
|
|
|
|
|
Hello,
I want to use SinatureCapturing (Saving the Signature in Sql Server Ce Database and Retrieving the Signature from Sql Server Ce Databse). from the MSDN Example: http://msdn.microsoft.com/mobility/understanding/articles/default.aspx?pull=/library/en-us/dnnetcomp/html/PPCSignatureApp.asp
I looked at this example and after one while I came to the realization that I have to use the SignatureControl.cs File and the Network.cs File.(I added this files to my application). Then I add the following code to my Main Form (I know that the database saving requires additional code, but I want only test at the beginning if the Control is displayed and if I am able to write on this Control with the pen.):
SignatureControl _signature = new SignatureControl();
and in the constructor:
_signature.Location = areaSignature.Location; //areSignature is the name of the panel
_signature.Size = areaSignature.Size;
this.tabPage2.Controls.Add(this.areaSignature);
I only added this code to the MainForm according to the constructor and FormLoad Method of the MainForm of the sample application. (I also set the sign here file to embedded resource of my application.)
But when I deploy the application the panel is displayed without any additional functionality or the bachground sign here.
Anybody an idea what I have forgotten?
robert
|
|
|
|