public interface ITest {
int Value { get; set; }
}
public class Test : ITest
{
public int Value { get; set; }
}
and:
public static class TestExtensions
{
public IEnumerable<T> TestExtension<T>(this IEnumerable<T> source) where T : ITest {
return source.Where(o => o.Value > 2);
}
}
this:
var tests = new[] {
new Test{ Value = 1 },
new Test{ Value = 2 },
new Test{ Value = 3 },
new Test{ Value = 4 },
};
tests.TestExtension();
When i executed following JavaScript code, i got undefined
var ns=new String('hello world');
String.prototype.capitalAll=function(){
this.toUpperCase()
};
alert(ns.capitalAll()); // undefined
But, when i add return, it ret...
@adeneo please don't say that something should be obvious. the op is asking because he/she doesn't know. we all had/have to start somewhere. — henry bemis20 secs ago
There is no lower bound for n00bity.
If I seem in a strange mood, that's because it's Friday.
On that note; are type constraints enough to differentiate method signatures, or are they still ambiguous? I'm getting no immediate errors, but I can't compile to check cause other stuff is broken in the file.
But that can be mitigated with the cast; which is fine. It's a shame the generic version doens't work; otherwise you could return T, working on the interface in the method body, with overloads.
@JonSkeet needs to come in here and pick up REBEL. Someone said something about you not knowing something about C#. Link: kendallfrey.com/projects/rebel.php
Error 1 The type or namespace name 'file' could not be found (are you missing a using directive or an assembly reference?) E:\MyTextProcess\MyTextProcess\Program.cs 28 18 MyTextProcess
Error 2 Type and identifier are both required in a foreach statement E:\MyTextProcess\MyTextProcess\Program.cs 28 23 MyTextProcess
@PeterJennings the declaration of file as a loop variable needs either var or string to identify it to the compiler. Do that and then the rest should be obvious
could you please let me know the equivalent code for this in c#
Dim files() As String files = Directory.GetFiles("E:\\myfolder", "*.txt") Dim filename As String Dim file As String For Each file In files filename = Path.GetFileName(file)
Oh, actually, no; the Apple Pie shots were bought by my roommate, and the bartender tacked on hers and mine on the house, and she poured herself and me a SoCo Lime shot.
@ShotgunNinja alcoholism is no laughing matter. It affects your physical and mental capacity. It makes it difficult for you to remem... what was I talking about?
Here is a review of her album Warrior on the New York Times. She is really cashing in on the "in this economy" theme. If I was to create a mascot today, it would be named Spend. We'd say Go Spend!
:8013778
//C# laughs it's ass off at VB trying to be... something other than suck
string[] files = System.IO.Directory.GetFiles(@"E:\myfolder","*.txt");
foreach(string file in files)
{
string filename = Path.GetFileName(file);
}
that's the simple version of it. you can get a bit more elegant if you want.
I'm not sure what you're trying to do, except get the filename of each file in that directory, if you are, what's your end goal with em?
When you work in a massive organization... it's wise not to use the phrase "Shoot so and So and email"... people get offended if you use the word shoot... (facepalm)
Today We had a glorious moment when the mid-tier team got the Edge Servers working to contact our ESB... Finally there's light at the end of the tunnel... then we found out that light was a f'n train in full speed with no breaks when we heard the news they used the wrong end point on the Edge...
I'm wondering if it's a good idea for a DAO and a BO to share an interface. Say an OrderBO and OrderDAO both use IOrder which contains the properties of an Order. Any thoughts?
No, I mean a custom interface that describes just the properties of an order. No DAL or BOL logic.
EG, an Order has an ID, a Customer and Line Items. Would it be a good idea to create an IOrder that has ID, Customer, LineItems and have OrderBO and OrderDAO implement it?
Then, in the OrderBO, I could have a method called Save that does something like this: public void Save() {
well, it's for a web service (currently refactoring huge business project). Right now, they have no layer separation, and they send back to the client the exact same object as the one that's used to populate the database.
Now, what I'm thinking is pulling out the interface that describes an object (say an Order), and then sharing that among the three layers. The service layer would return just the data and handle logging of incoming data. BL would handle BL and DAL would read/write to the databases.
But because the objects aren't really changing very much as far as properties (obvious differences in implementation and such), I was wondering if it was valid to have the three layers communicate their values by sending themselves to each other via their shared interface instead of using DTOs.