|
adrian564 wrote: I get a message which does not help
Can you post the message here?
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Hello all,
I would appreciate any help that can be given. I'm new to c# and mostly develop in c++. I'm using Microsoft Visual Studio 2010 as my IDE. My question is I'd like to ouput cars from a car collection. I'm using a 3rd party DLL library. As far as I know the dll has 2 classes. They are CarCollection and Car.
CarCollection has the following functions:
using System;
using System.Collections.Generic;
namespace CaraPartnersSdk
{
public class CarCollection
{
public CarCollection();
public IEnumerable<Car> FindByName(string name);
public Car GetByID(int id);
}
}
Car.cs:
using System;
using System.Collections.Generic;
namespace CaraPartnersSdk
{
public class Car
{
public Car();
public string AlternateForm { get; }
public Condition Condition { get; }
public IEnumerable<Car> ConnectsToCars { get; }
public bool HasBeenOpened { get; }
public int ID { get; }
public string Name { get; }
public string OptionalAttributesXml { get; }
public decimal Price { get; }
public string Set { get; }
public int Strength { get; }
}
}
All I'm trying to do is output each Car's name and ID which is in the dll. For now, I'm using a simple main class. I have no idea how to iterate through the CarCollection since it's not an array or actual collection. I'm doing CarCollection aCollection = new CarCollection(); When I use aCollection.FindByName() I get a message which does not help. After that I'm stumped. I know I have to use public IEnumerable<Car> FindByName(string name); from the CarCollection class but I have no idea how. I wish they passed the collection as an array because then I can do a simple for loop like
for(int i = 0; i
{
collection(i).getName();
}
something like that, but I guess thats not the case. Please I would appreciate any help. Thanks.
-Adrian
|
|
|
|
|
hi,
this might be one of the way to solve it. you can use LINQ query to do it in a neat way
IEnumerable<string> carnames = from cars in car
select cars.name;
foreach(string cr in carnames)
{
//do whatever with cr
}
i feel linq is really a nice concept introduced.. infact i have become a fan of it.
in above u can specify the 'where' condition also as per your need..
Hope this helps u...
Regards
Samir
|
|
|
|
|
Hello,
I'm still really confused, so I tried this
IEnumerable<string> carnames = from cars in Car
select cars.name;
The error I get is error CS1936: Could not find an implementation of the query pattern for source type 'CaraPartnersSdk.Robot'. 'Select' not found.
I'm real confused I just want to print out the string name of the car. Please help.
Best,
Adrian
|
|
|
|
|
Hello,
I'm still really confused, so I tried this
<pre>
IEnumerable<string> carnames = from cars in Car
select cars.name;
</pre>
The error I get is error CS1936: Could not find an implementation of the query pattern for source type 'CaraPartnersSdk.Robot'. 'Select' not found.
I'm real confused I just want to print out the string name of the car. Please help.
Best,
Adrian
|
|
|
|
|
Anyone? any suggestions? Maybe a helpful book or website?
Thanks.
|
|
|
|
|
To enumerate an enumerator, all you need is a foreach statement.
I'm also assuming that FindByName can take a wildcard.
But, as you still haven't told us what error you were getting, we still don't know!
modified on Wednesday, April 7, 2010 11:29 PM
|
|
|
|
|
Hi,
I have some hands on experience in developing .net web applications .Now i am thinking about developing components (Like charting components,HTML to pdf etc) which can be referenced in .net applications. For eg like the one mentioned in http://www.dotnetcharting.com/[^] . I know it will take time and effort to create stuff like that . But i want to the basic steps in developing components like this . Is these are com components? (C++) or can we develop the same in pure .net code?
Thanks
|
|
|
|
|
Hi all,
I am using Visual Studio 2005/2008, I tried to use the OpenFileDialog to open file.
But I would like to know what codes/settings do I need if I want to let the users only select one floder and all files in it would be opened?
Thanks very much!
modified on Monday, April 5, 2010 1:08 AM
|
|
|
|
|
Hi,
how about using the FolderBrowserDialog class to let the user choose a folder, then use Directory.GetFiles() to get a list of all files, and finally open those files in whatever way you think appropriate, either reading them yourself inside your app, or launching them with Process.Start()
|
|
|
|
|
Thanks Luc!!
It sounds link a good solution for me! However, I am really too lack experience in write such a program.. I got a warning of "No overload for method 'GetFiles' takes '0' arguments..
How can I resolve this?
|
|
|
|
|
whatever the problem is, there are three steps to a solution:
1. read the documentation (in this case, it will tell you GetFiles takes 1 or 2 or 3 parameters);
2. if that did not work, search the web, i.e. ask Google
3. and if that failed too, ask on a forum like CodeProject.
FYI: if you're new to programming language, or to programming in general, I strongly advice you to buy a book of your choice, and study it thoroughly. That will teach you the fundamentals, in a structured way, and at a much higher pace than you can achieve by experimenting and asking around.
|
|
|
|
|
Thanks =p
I would try to google more and search on the msdn page. My project is quite urgent that there would be no time for me to read a book =\
Thanks again Luc!
|
|
|
|
|
you're welcome.
|
|
|
|
|
When i display a Cursor object in a property grid i get a dropdown menu with all the custom cursors and associated images. Is there a way to do this with a custom object so i can display custom images in the same format.
I have found an article on this site that give a way to display little rectangle images in the property grid but the cursor images are different. with the cursor the images are larger and square they are also not shown when the dropdown list isnt shown.
Can anyone tell me how i can imitate this effect with a custom object or maybe help me to modify the Cursor object to show custom txt and images.
|
|
|
|
|
good day to everyone. i just want to know how to hide tables in ms sql using c# codes. because, i want to hide the tables so that no one will be able to edit or even delete the tables i've created.thank you very much in advance...
|
|
|
|
|
accessing a database can be restricted using usernames and passwords.
|
|
|
|
|
thanks for the reply...but is there a way to hide the tables just for add-up securty?thanks again...
|
|
|
|
|
I don't think so, and I don't see a need.
Create your app with the functionality you want, and no more; give it a connection string that provides access to the database; and store that connectionstring in a settings file, outside the app, but encrypted, so the world can't use it, only your app can.
|
|
|
|
|
thank you again for the reply...i'm developing a web service which accessed the registry to get some info about some app...i want to save that info to a file or database which the other users won't be able to edit nor delete anything on it or the file itself...can you give me some options for a more secured way...thanks a bunch...
modified on Monday, April 5, 2010 1:31 AM
|
|
|
|
|
Assuming your Web Service runs in IIS, give the user account executing the web service AppPool permissions to access the database table. Do non give these permission to any other user account (excpet administrative account).
Doing so the access to the table will be possible only through your Web Service.
|
|
|
|
|
Hello!
I have a table in msSql called Products, and I have a sproc called: sp_Products_selectQuantity witch uses
1 parameter called: @productID.
sproc code is:
select productQuantity from Products where (ProductID = @productID)
Now: In my visual studio formX, i have a have a field called double_ProductQuantity...
How do my vs field gets value from sql?
help?
Dragan Gojkovic
|
|
|
|
|
I guess Google is not available from where you are at.
This is such a simple question that you could most likely stumble blindly in any forum and find the answer.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
thanks a lot! How didn't I thougth of that...
|
|
|
|
|