|
Hi,
I understand your pain. Wouldn't it be nice to be able to write:
dinosaurs.Find(EndsWith("saurus"));
A little bit of code is required to get a variable into the predicate.
public class StringPredicate {
String stringToMatch;
public StringPredicate(String toMatch) {
this.stringToMatch = toMatch;
}
public Boolean EndsWith(String s) {
if ((s.Length > 5) && (s.Substring(s.Length - 6).ToLower() == this.stringToMatch)) {
return true;
} else {
return false;
}
}
}
Now you may call the List.Find method like this.
dinosaurs.Find(new StringPredicate("saurus").EndsWith);
Easy when you know how!
Alan.
[edit] Version2, a slight rejig of the code
public class StringPredicate2 {
String stringToMatch;
private StringPredicate2(String toMatch) {
this.stringToMatch = toMatch;
}
private Boolean Match(String s) {
if ((s.Length > 5) && (s.Substring(s.Length - 6).ToLower() == this.stringToMatch)) {
return true;
} else {
return false;
}
}
public static Predicate<String> EndsWith(String searchTerm) {
return new StringPredicate2(searchTerm).Match;
}
}
Now you may call using a more natural form:
dinosaurs.Find(StringPredicate2.EndsWith("saurus"));
modified on Monday, August 3, 2009 9:34 AM
|
|
|
|
|
So you want a generic find method which can find any string in your list, right? Try this,
string Find(List<string> list, string itemToFind)
{
return list.Find(item => item == itemToFind);
} Lambada expressions makes it very easy.
|
|
|
|
|
If it's a list, you need to search it. (And there could be duplicates.)
If you convert it to a HashSet you don't.
|
|
|
|
|
how can i program a microcontroller in c#??
i want asource code for the main programming
|
|
|
|
|
lollipop1312 wrote: how can i program a microcontroller in c#??
i want asource code for the main programming
Well, I doubt you can, but I'd try to write you one for a standard contract rate ( say, $120 an hour ). You didn't expect someone to write it for free, did you ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
thanx
but dont u think thats too expensive
|
|
|
|
|
$120 an hour for a custom programming job on custom hardware?? That's actually pretty cheap...
|
|
|
|
|
To add to what Christian said, see this thread from last week: Can-I-write-programs-in-C-sharp-to-Micro-Controllers[^]
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
That is a tough job. You need:
- a C# compiler or cross-compiler (the .NET one running on a PC would be fine),
- a virtual machine running on your target machine;
- as much of the .NET classes as your VM and your app are going to use.
Creating it from scratch is doable in theory, as it is similar to programming a micro-controller in Java, however the effort required exceeds several man-years of expert development. You feeling the need to ask (and the content of your subject line) disqualifies you for the job.
Starting from an existing system such as Mono, I can't tell as I haven't looked into it in any detail. I trust it would still be a major job.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Basicly what I am tring to do is change a files properties to super hidden.
(or system hidden) like the protected operating files. read about a way to do this manually
with the cmd.exe(comand line). one could probably build a batch file to do this. But the clean
way would be to do it with in the C# application that creates the file in the first place.
But Im not sure how to go about doing it. the "File.Atributes" only has the general type properties
.It has "hidden" and also "System". But what I need to do is tuck away a file that my program can access And be sure that it wont get deleted or changed.
Any Help would be greatly Appriceated.
Regards;
Rick
|
|
|
|
|
FileInfo.Attributes is the property you are interested in!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
No matter what you do some users will find a file on my system if I really need to, if it is malicious then tough, if your are looking at a licencing type system then there are better ways, mind you they do cost money. Or you can use encryption and leave it in the open.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Do bear in mind that there are options in the file and folder explorer to show hidden and system files? I don't think you can do what you want that easily.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
What I am doing is developing a Licensening application. Dont wont to buy a program to do it.
Figure I could build my own and learn in the process. I liked the message about inconvienced
electrons. very funny.
Regards
|
|
|
|
|
hello all;
i have a c# code which generates TCP packet and send it on the LAN. but this code does not allow me to enter my data to send.
i have tried to add data field and link it with send function but i does not do this. i have also tried TCP.Data field to enter my data but no good result.
i want to ask you all genius persons, how could i add my data field in this code. Simply what i want is to send my data to LAN. if any generous has simple code that can do this, kindly give it to me.
thanks in advance.
regards
akqureshi
|
|
|
|
|
Hi,
Is anyone can help me? please.
I have a small project that I need to view a certain document file in my program, example a .doc file.
Is there any class or a control that I can used to view this certain document?
You're help is appreciated.
Thanks in advance.
regards,
erson
|
|
|
|
|
That very much depends on the document type!
But chances are, the System.Windows.Forms.WebBrowser or System.Windows.Controls.Frame might help you.
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Hi to all,
i'm planning to create a new system using Visual studio for my company. but how am i suppose to create the system so that when the users wants to use this system he or she must install before he can use. besides that the users does not have a database system like SQL, how are they going to save the data or read from the data i created in my DB. are they suppose to install the DB as well ??
thanks
Warm Regards
Veon
|
|
|
|
|
veon cheng wrote: but how am i suppose to create the system so that when the users wants to use this system he or she must install before he can use.
Visual studio can make installer files for you. It offers a package and deployment kind of project template.
veon cheng wrote: besides that the users does not have a database system like SQL, how are they going to save the data or read from the data i created in my DB. are they suppose to install the DB as well ??
Is this a stand-alone application and database is centralized? If yes, requesting users to install a copy of DB is a poor idea. You can keep the DB in your server and provide an interface to access it (web service or WCF).
If all your users need separate database instances, they need to install DB on their machines. However, if the data to be stored is small and doesn't require a complex RDBMS system, you can use file system databases like SqlLite[^].
modified on Sunday, August 2, 2009 11:47 PM
|
|
|
|
|
hi Navaneeth,
Thanks for replying. ok, my company will be running the admin of this system, it has a number of outlets will be using this system as well how am i suppose to make the system communicate. for example there is some update in outlet A. And i wan all the other outlets and the admin system to update the info of outlet A to all the system. i'm very confuse in planing the system right now. pls give me some advice ,Thanks
Warm Regards
Veon
|
|
|
|
|
veon cheng wrote: how am i suppose to make the system communicate. for example there is some update in outlet A. And i wan all the other outlets and the admin system to update the info of outlet A
Hard to tell without knowing much about your systems. One way to do is keeping a centralized database. All updates should go to this DB. So your systems can poll this DB and display the changed data.
|
|
|
|
|
First of all you need to know the purpose of your system. Design the for accordingly, Design Database. Now try to implement it step by step. After complete,, make the installer of your system from visual studio it.
This link will help you,
C#
|
|
|
|
|
hi to all
Thanks for replying. ok, my company will be running the admin of this system, it has a number of outlets will be using this system as well how am i suppose to make the system communicate. for example there is some update in outlet A. And i wan all the other outlets and the admin system to update the info of outlet A to all the system. i'm very confuse in planing the system right now. pls give me some advice ,Thanks
Warm Regards
Veon
|
|
|
|
|
Your requirement is similar to a Point of Sales / Retail system.
The outlet has to keep an offline database, and synchronize with the server periodically or at end of day. New or updated data from outlet shall be sent to centralized server, and latest data will be downloaded from server and updated in the offline database.
The communication can be lease line, dial up, or through internet (you will need a DNS or fix IP for this).
The logic of synchronization is the difficult part, especially the master data from the outlet to the server.
I would suggest you approach vendors of existing system, instead of creating your own from scratch while without much experience in this field.
|
|
|
|
|
Are you actually going to build the system or be the business contract to the builder of the system.
I fear it is the former - attempting to build this solution with no prior knowledge of applications design is going to be very difficult.
I don't want to discourage you, no thats a lie, hire a professional to do the job, work closely with that person in the knowledge that you will be supporting the finished app and learn as much as possible. This will achieve few things, your company may get a good solution, you may get to learn about application sdesign and development, your copany will benifit from having a knowledgable support person in place.
Never underestimate the power of human stupidity
RAH
|
|
|
|