|
thanks, can't wait to get my hands on the C# 2.0.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
What Corinna was saying about .NET 2.0 would be the List<> class. You can use that like so:
List<int> ints = new List<int>();
ints.Add(1);
ints.Add(2);
ints.Add("blah"); Besides using a generating you can currently extend CollectionBase , which uses an ArrayList internally. You define your methods to be typed according to the Type you want to accept.
Using this is a good way to produce more portable code. If you extend CollectionBase now, you can easily extend List<> later and just remove your CollectionBase overrides:
public class IntList : CollectionBase
{
public int Add(int value)
{
return List.Add(value);
}
public void DoSomething()
{
}
}
public class IntList : List<int>
{
public void DoSomething()
{
}
} See how easy that can be? Without changing your code that uses IntList you can change the base type and avoid boxing (since casting or treating a value type like int as a reference type object requires boxing).
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
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Hello, I have just acquainted myself with C# and .NET and I have a question. I see there are some C# classes that represent Crystal report files and report interfaces (*.rpt and *.xsd) and I want to find out how do these classes work.
Thank you.
|
|
|
|
|
.xsd is an XML schema file, first of all. You can use these to define fields for a report that you can later bind to a DataSet (disconnected recordset) using ReportDocument.SetDataSource .
Using Crystal Reports for Visual Studio .NET is documented in the product documentation. Read Crystal Reports[^] in MSDN online for more information.
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]
|
|
|
|
|
Hi! All,
please help me to create Dynamic Cursor files at run time.
|
|
|
|
|
This request is well beyond the scope of this forum about writing in and using C#. If you want to create cursor files at runtime you need to understand the structure of a cursor blob (data), which is documented in the Platform SDK.
Read about Resources[^] in MSDN Online for information about the cursor data structures.
If you need help declaring such structures in C# and serializing them to a file stream, first read Marshaling Data with Platform Invoke[^] in the .NET Framework SDK. If you have further questions about how to do this in C# - if indeed you're trying to do this in C# - you can ask here.
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 want to get the selected text in an opened browser window programmatically from another winodw application that I created. I've to use SenKeys.SendWait("^C") function But it didn't solve my problem.
Or
I've created a object for a toolbar with some button.
That toolbar is added to InternetExplorer I want to select some text
from any page opened in the browser then click on that button to pass the
selected text from the page to the clipboard. So, I though to access
CTRL+C programmatically and I did using SenKeys.SendWait("^C") . But it didn't copy the selected text, I thought it loose focus from the area of
the page. so I tried to get refence to that area from the browser like
using
this.FindForm()
this.Parent
this.TopLevelControl
this referes to my button or the toolbar control that contains that
button.
I want o use:
bowserWindow.Focus()
SenKeys.SendWait("^C")
but all the trials to get reference to browser window returns null. I
tried to get refrence to the IEXPLOR process and succeeded and from it
got the handler of the window but couldn't cast it to a window.
Summary: I want to copy the selected text from body of the broswer page
programmatically from the toolbar button action or from another application
egyseiko
|
|
|
|
|
The best, most practical way of doing this is just accessing the DOM (document object model) for the body. Reference the Microsoft.mshtml.dll assembly in your project and add using mshtml; to the top of your source to import the namespace.
Cast the AxWebBrowser.Document property to IHTMLDocument2 , which defines the body property. From that you can get either the innerHTML or innerText . If this seems familiar in terms of web development with DHTML, it's because you're walking the same DOM that script uses that is exposed by MSHTML, the HTML parser and renderer for the WebBrowser control (which is actually IE, not just iexplore.exe):
IHTMLDocument2 doc = (IHTMLDocument2)axWebBrowser21.Document;
if (doc != null)
{
IHTMLElement body = doc.body;
if (body != null)
bodyText = body.innerText;
} Hosting the WebBrowser control or MSHTML itself and accessing the DOM is what most clients do, and it allows you to access the full HTML DOM that script can.
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]
|
|
|
|
|
Actually, I can't get access to the instance of the current opened browser window. I'm not using WebBrowser control. So, how can I got that refrence you refered to as
AxWebBrowser.Document
egyseiko
|
|
|
|
|
I am writing a program that requires array types and dimensions be decided at runtime. I can use System.Array.CreateInstance() to do this. What is the most efficient way to access the data in this array? I know I can use the getValue and setValue methods. I can also use the enumerable interface when allowed by the situation. Both of these are however inconvenient when compared to indexing the values using [].
Does anyone have any suggestions. Efficiency of the code is a major consideration.
Thanks,
Karl
|
|
|
|
|
If you expect the modify the array while enumerating you cannot use IEnumerable . It will throw an exception if the underlying enumerable changes.
Why not just use an ArrayList ? It has the same read performance as an array because it uses an array internally. It's only when you add elements past the current capacity that there is overhead since a new array is created (doubling in size) and previous elements are copied.
Dynamic code is often an inconvenience, but there's not much you can do short of wrapping such behavior (which, once again, ArrayList already does for you - just examine the IL for yourself or use a decompiler like .NET Reflector). Ever written native code to access automation (IDispatch implementations) servers? It's a pain compared to automation clients like VB6 and script, but that's the price to pay for late-binding code.
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 your response.
As I understand the ArrayList and all other collections provide lists of objects. My arrays will contain standard types such as byte, int, float...
As a result if I use a collection there will be a large performance hit (boxing,unboxing,longer value retreval times).
Thanks
Karl Baum
|
|
|
|
|
An array is an IList implementation, which inherits from ICollection which inherits from IEnumerable . As I said - and as you can see in the IL module where ArrayList is defined - the ArrayList (and, hence, any collections that use an internal ArrayList ) - do use arrays that are doubled in capacity before that capacity is exceeded.
There will only be a performance hit if you collect value types (like primatives, not "standard" types). Boxing and unboxing only describes the process that the CLR performs when treating a value type as an object and back again, respectively.
In .NET 2.0, of course, you could simply use List<> to declare a generic list for whatever type, reference or value types.
If performance is a problem now and you can't or don't want to use .NET 2.0 (granted, it's still in beta 1 but beta 2 is due out shortly) than you'll need to use what you're doing now to create arrays. Again, though, I urge that you wrap such functionality in a class. Later you can derive that class from List<> and remove your implementation. Now you won't have to change your calling code. Just make sure to use the same signatures as List<> , which you can find at http://msdn2.microsoft.com/library/6sh2ey19.aspx[^] (the new namespace extension to MSDN2 doesn't appear to be functioning just yet for generics, so I can't give you the simple change-tolerant link).
Basically, you'd just implement your own ArrayList -like class. It's really not hard. If you know IL, use ildasm.exe that ships with the SDK (that's installed by default with VS.NET) or use a decompiler like .NET Reflector to see how ArrayList operates if you can't figure it out based on the documentation. You're already part way there with what you're doing.
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]
|
|
|
|
|
Thank you for your response,
I understand how all of this works, and was just wondering if c# contained anything I wasn't aware of. It appears I will have to continue doing it as I have been.
ArrayLists and the other collections are simply not appropriate for what I am trying to do. The functionality they provide come with too much of a performance hit. The implementation of ArrayList is significantly different from what I am trying to do. ArrayList's power and weakness come from it being a list of references, and hence you can stick anything in there, at the expense of following the references. What I am looking for is a standard array (one continuous chunk of memory, with only one reference to the array itself).
Thanks for your help and suggestions. Particularly your suggestion for easier transition over to the new capabilities that will be provided by 2.0.
Karl Baum
|
|
|
|
|
Hi All
I am not using the toolbox to place a textbox
Instead i want to generate code for placing the text box on page_load
i used the following code:
Label lblMessage=new Label();
lblMessage.Text="ID";
lblMessage.Controls.Add(System.Web.UI.Control Label);
is there ne other way coz this does not work.
Sukanya
|
|
|
|
|
First of all you have to use TextBox class insted of Label Class and you should set a location for that control in addetion to its dimenssions
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
You do exactly what you see in the source code when use the designer. There's no magic like with VB6 using hidden code (though the designer region of code is collapsed, but you just expand it). Look at the source code and don't depend so much on what the designer does.
As the first reply stated, if you want a ,TextBox than use a TextBox , not a Label . But you must add the instance that you instantiated (in your example, that would be lblMessage ) to the contorl collection for the parent control:
TextBox tbMessage = new TextBox();
this.Controls.Add(tbMessage);
tbMessage.Location = new Point(8, 8); Just look at the source code that the designer used. You can do all that manually, too. Most application I write I don't use the designer at all, and it results in the same code.
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]
|
|
|
|
|
"enumerate all the ways of making change for X cents."
For example, if given 10 cents, the possibilities include:
10 pennies, 5 pennies and 1 nickel, 2 nickels, and 1 dime.
You can assume the allowable denominations are pennies,
nickels, dimes and quarters.
cents : number of cents that you should enumerate the
change possibilities for (for example, 82)
Above C# Code used should be non-recursive.
|
|
|
|
|
Wow - there's a piece of real world code if ever I saw one.
I'm happy to do your homework. For $5. When the next assignment comes, and you can't do it because it assumes you know how to do this one, I'll charge you $10. And so on.
OR, if your daddy isn't that rich and/or you actually want to be a software developer one day, think about the problem in terms of the tools you've been given ( i.e. what they taught you in class ), and if you get stuck, post your code and ask for help. Then I'll help for free.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
As what a great mutant once said, "Sometimes the mind needs to discover things for itself."
I certainly agree with Christian and will certainly encourage you to stretch your God given nuts!
|
|
|
|
|
i had problem in returning a DataReader object from a ServicedComponent class. The dataset object was return fine, but when return the DataReader, the datareader object was a transparent_proxy object. I dont understand why only the return DataReader object is a transparent_proxy?
And if i use any method of the returned DataReader, the following error will be occur:
This remoting proxy has no channel sink which means either the server has no registered server channels that are listening, or this application has no suitable client channel to talk to the server.
my codes is simplied as follow:
//First layer is DataAccess Layer
public sealed class DataAccess : ServicedComponent
{
//others methods here...
public OleDbDataReader ExecuteReader (OleDbConnection objConn, string
sql, CommandType commandType, OleDbParameters paramList)
{
//SomeOthers codes here...
return objCmd.ExecuteReader(CommandBehavior.CloseConnection);
}
}
//Second Layer is Data Access Logic
public class EmployeeDAL : ServicedComponent
{
public IDataReader GetEmployeesFirstName()
{
//someothers codes here...
DataAccess objDa=new DataAccess();
OleDbConnection objConn=new OleDbConnection();
return objDa.ExecuteReader(objConn,sql);
}
}
Thanks in advance for your help.
gkb
|
|
|
|
|
my project is to reuse current C++ application modules and create a whole new web-based GUI.
My question is, when i convert my C++ application into DLL. Can i use C# to import that DLL and then use ASP.net to create front-end for that application? as i know that ASP.net can use C# as code-behind.
if all above can work. can anybody provide a simple example to let me test it out. I don't know how to create C++ DLL in Visual Studio.Net 2003. Can anybody give me a useful link. So that i can try to create a simplest hello world example.
Thanks for viewing
regards;
webdevelopex
|
|
|
|
|
Why do you need to create the dll, isn't it preexisting ? Is it a COM dll, or a normal one ? Either way, there's no reason i can see why you can't use C# to call it from ASP.NET, just as you would in C# in any other application.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I meant not the preexisting C++ DLL, it is something like COM dll or my own created DDL. But i am not sure that the DDL created in visual studio 6.0 can be use in C#? If yes, that's mean i can use ASP.net to call the function in my own DDL which was created in visual studio 6.0.? and the C# will act as a middel man between ASP.net and C++ DLL(created in visual studio 6.0).
anywhere, thanks for repied. Cheers!!!
|
|
|
|