|
Hi there,
I am trying to find information about the file metadata in Windows. Every file
has a summary tab page in its general properties. Where is that information stored?
I want to access and modify this data (the Keywords field in particular) from within C#.
I couldn't find anything useful online. Maybe some of you guys can enlighten me.
cheers from Germany...
|
|
|
|
|
Ok, before you read all the code I am Telling you this IS a homework assignment. My professor is not helping out very much with it (for me) and I just do not understand how to get this working. I would like to not have the code handed to me but would like some good advise on how to complete this.
namespace IT274_U2
{
public interface IAnimal
{
string WhatAmI { get; }
string WhatIsMyName { get; }
}
abstract class Animal : IAnimal
{
private string _WhatAmI;
private string _WhatIsMyName;
public string WhatAmI
{
get
{
return _WhatAmI;
}
}
public string WhatIsMyName
{
get
{
return _WhatIsMyName;
}
}
}
class Dog : Animal
{
}
class Cat : Animal
{
}
public class TesterClass
{
static void DescribeAnimal(IAnimal animal)
{
Console.WriteLine("My name is {0}, I am a {1}", animal.WhatIsMyName, animal.WhatAmI);
}
static void Main(string[] args)
{
Dog mydog = new Dog("Dog", "Spot");
Cat mycat = new Cat("Cat", "Felix");
DescribeAnimal(mydog);
DescribeAnimal(mycat);
}
}
}
Ok I have the Interface IAnimal. Now I needed to make an abstract class Animal (required). Ok Now how do I implement new dog() and new Cat() if I cannot include another public void Dog(string _WhatAmI, _WhatIsMyName) ?? Because that has to be in there somewhere because it requires 2 arguments?!?!
I am way confused on this....
|
|
|
|
|
First off, in your Animal class you will need to change the _WhatAmI and _WhatIsMyName variables to protected. A protected variable is exactly the same as private except that derived classes can access the variable. If your not sure what I mean, then try to acces the variable _WhatAmI from the Dog or Cat classes and see what happens.
Now, when you call new ClassName it creates a new instance of the class and the classes constructor is automatically called. So, you need to create a constructor for your Dog and Cat classes which takes the two string parameters.
MSDN on access modifiers[^]
Lots of info on constructors[^]
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Ok it compiles without errors but does not return a value..
I know what is wrong.. assigning _WhatAmI.
But I have to figure out how to assign WhatAmI and WhatIsMyName to _WhatAmI and _WhatIsMyName
right? But it is read-only.
namespace IT274_U2
{
public interface IAnimal
{
string WhatAmI { get; }
string WhatIsMyName { get; }
}
abstract class Animal : IAnimal
{
protected string _WhatAmI;
protected string _WhatIsMyName;
public string WhatAmI
{
get { return _WhatAmI; }
}
public string WhatIsMyName
{
get { return _WhatIsMyName; }
}
}
class Dog : Animal
{
public Dog(string _WhatAmI, string _WhatIsMyName)
{
_WhatAmI = WhatAmI;
_WhatIsMyName = WhatIsMyName;
}
}
class Cat : Animal
{
public Cat(string _WhatAmI, string _WhatIsMyName)
{
_WhatAmI = WhatAmI;
_WhatIsMyName = WhatIsMyName;
}
}
public class TesterClass
{
static void DescribeAnimal(IAnimal animal)
{
Console.WriteLine("My name is {0}, I am a {1}", animal.WhatIsMyName, animal.WhatAmI);
}
static void Main(string[] args)
{
Dog mydog = new Dog("Dog", "Spot");
Cat mycat = new Cat("Cat", "Felix");
DescribeAnimal(mydog);
DescribeAnimal(mycat);
Console.ReadKey();
}
}
}
|
|
|
|
|
Jacob Dixon wrote:
public Dog(string _WhatAmI, string _WhatIsMyName)
{
_WhatAmI = WhatAmI;
_WhatIsMyName = WhatIsMyName;
}
See the problem here is that the variables supplied to the constructor have the same name as the class' variables, which means that the variables in the constructor are hiding the class' variables. Second, you tried to set your properties WhatAmI etc, which only have get implemented, which is why you got the read-only error. The variables you need to set are _WhatAmI and _WhatIsMyName.
What you need to do is something like this:
public Dog(string what, string name)
{
_WhatAmI = what;
_WhatIsMyName = name;
}
So, in this case you would be setting the variables _WhatAmI and _WhatIsMyName which are defined in your abstract class, to the variables what and name which are passed to the constructor.
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
I got it to work! Thanks.. let me know what you think about this:
Ok tell me if I am wrong but as you said you do protected string so Dog and Cat have access to it. Now pass the information to Dog() and Cat(). which sets the values for _WhatAmI and _WhatIsMyName in the abstract class Animal. which returns the value for output.. correct?
namespace IT274_U2
{
public interface IAnimal
{
string WhatAmI { get; }
string WhatIsMyName { get; }
}
abstract class Animal : IAnimal
{
protected string _WhatAmI;
protected string _WhatIsMyName;
public string WhatAmI
{
get
{
return _WhatAmI;
}
set
{
_WhatAmI = value;
}
}
public string WhatIsMyName
{
get
{
return _WhatIsMyName;
}
set
{
_WhatIsMyName = value;
}
}
}
class Dog : Animal
{
public Dog(string WhatAmI, string WhatIsMyName)
{
_WhatAmI = WhatAmI;
_WhatIsMyName = WhatIsMyName;
}
}
class Cat : Animal
{
public Cat(string WhatAmI, string WhatIsMyName)
{
_WhatAmI = WhatAmI;
_WhatIsMyName = WhatIsMyName;
}
}
public class TesterClass
{
static void DescribeAnimal(IAnimal animal)
{
Console.WriteLine("My name is {0}, I am a {1}", animal.WhatIsMyName, animal.WhatAmI);
}
static void Main(string[] args)
{
Dog mydog = new Dog("Dog", "Spot");
Cat mycat = new Cat("Cat", "Felix");
DescribeAnimal(mydog);
DescribeAnimal(mycat);
Console.ReadKey();
}
}
}
|
|
|
|
|
You can add these changes:
public abstract class Animal : IAnimal
{
public Animal(string WhatAmI, string WhatIsMyName)
{
_WhatAmI = WhatAmI;
_WhatIsMyName = WhatIsMyName;
}
....
public class Cat : Animal
{
public Cat(string WhatIsMyName) : base ("Cat",WhatIsMyName)
{
}
}
Although, I would have used an abstract method in animal called GetDisplayName which would be overridden in the subclasses..
modified on Saturday, May 24, 2008 5:17 AM
|
|
|
|
|
So something like this?
namespace IT274_U2
{
public interface IAnimal
{
string WhatAmI { get; }
string WhatIsMyName { get; }
}
public abstract class Animal : IAnimal
{
private string _WhatAmI;
private string _WhatIsMyName;
public Animal(string WhatAmI, string WhatIsMyName)
{
_WhatAmI = WhatAmI;
_WhatIsMyName = WhatIsMyName;
}
public string WhatAmI
{
get
{
return _WhatAmI;
}
set
{
_WhatAmI = value;
}
}
public string WhatIsMyName
{
get
{
return _WhatIsMyName;
}
set
{
_WhatIsMyName = value;
}
}
}
public class Cat : Animal
{
public Cat(string WhatAmI, string WhatIsMyName) : base ("Cat",WhatIsMyName)
{
}
}
public class Dog : Animal
{
public Dog(string WhatAmI, string WhatIsMyName) : base("Dog", WhatIsMyName)
{
}
}
public class TesterClass
{
static void DescribeAnimal(IAnimal animal)
{
Console.WriteLine("My name is {0}, I am a {1}", animal.WhatIsMyName, animal.WhatAmI);
}
static void Main(string[] args)
{
Dog mydog = new Dog("Dog", "Spot");
Cat mycat = new Cat("Cat", "Felix");
DescribeAnimal(mydog);
DescribeAnimal(mycat);
Console.ReadKey();
}
}
}
Ok It works, but I do not really understand where base() comes from. Now how does this work even though the methods Dog() and Cat() have nothing in them?!?
|
|
|
|
|
Ok I am been deleting things and looking at the errors it throws to try to understand this better. So when you use BASE it derives from the class that the class it is in derives from right?
So BASE is passing two arguments to public class Animal().
Now my question is, when you do this you have it setting the string _WhatAmI to WhatAmI(which was the constructor in Animal that base("Cat", WhatIsMyName) sent to it. See you still have to implement WhatAmI and WhatIsMyName as public strings so it will not throw an error. You have to implement them because they are in the Interface right?
so:
public string WhatAmI
{
get
{
return _WhatAmI
}
}
now that is setting _WhatAmI to. So now we have two areas in the coding that sets _WhatAmI, correct? No wait.. that is RETURNING the value of _WhatAmI to the string WhatAmI from the Interface... Let me know if I am wrong so far. So we are setting the private strings value in the method Animal(). Then we are creating public strings so it implements the Interface class. Then in those public strings we are setting the values in the Interface class. That Is why public string WhatAmI(get;) is in the interface. Because when you pass them to the Interface class it has to GET those strings you are passing.
So since we have Cat(string WhatAmI, string WhatIsMyName) ... which has to be there because you have to have it take 2 constructors the code : base("Cat", WhatIsMyNAme) is passing it directly from the method Cat() to the method Animal() since base is the class that Cat() derives from.
I hope I get got that right because if I did Im starting to get a much better understanding!!
|
|
|
|
|
Sorry about my last post I forgot to put the /pre in and it screwed everything up!
Ok I am been deleting things and looking at the errors it throws to try to understand this better. So when you use BASE it derives from the class that the class it is in derives from right?
So BASE is passing two arguments to public class Animal().
Now my question is, when you do this you have it setting the string _WhatAmI to WhatAmI(which was the constructor in Animal that base("Cat", WhatIsMyName) sent to it. See you still have to implement WhatAmI and WhatIsMyName as public strings so it will not throw an error. You have to implement them because they are in the Interface right?
so:
public string WhatAmI
{get
{
return _WhatAmI
}
}
now that is setting _WhatAmI to. So now we have two areas in the coding that sets _WhatAmI, correct? No wait.. that is RETURNING the value of _WhatAmI to the string WhatAmI from the Interface... Let me know if I am wrong so far. So we are setting the private strings value in the method Animal(). Then we are creating public strings so it implements the Interface class.
Then in those public strings we are setting the values in the Interface class. That Is why public string WhatAmI(get is in the interface. Because when you pass them to the Interface class it has to GET those strings you are passing.
So since we have Cat(string WhatAmI, string WhatIsMyName) ... which has to be there because you have to have it take 2 constructors the code : base("Cat", WhatIsMyNAme) is passing it directly from the method Cat() to the method Animal() since base is the class that Cat() derives from.
I hope I get got that right because if I did Im starting to get a much better understanding!!
|
|
|
|
|
Jacob Dixon wrote: My professor is not helping out very much
Some times that's the best kind of help.
Animal, Dog, and Cat will need constructors (as I think you know by now).
I wouldn't bother storing the WhatAmI, but instead access the name of the type, otherwise you can get:
Dog mydog = new Dog("Tiger", "Spot"); , maybe just do a sanity check on the passed value, but it's a poor design.
As it's homework I suggest the use of an automatic property for WhatIsMyName.
|
|
|
|
|
yea he didn't like how I did it. He is saying the strings in Animal should be private not protected. He is saying I should not have access to those directly but through properties.
|
|
|
|
|
Hi all,
I have a application that receives a data buffer from TCP\IP, and save the buffer with the corresponding timestamp the event ocurred.
Now I need to simulate the TCP\IP data arriving just by reading the log, but using the timestamp information, to receive the events along with the same timings I would if using the original channel.
This code isn't hard but it would be good to get something ready for use. I'm sure this kind of requirement is not new.
Any tips ?
Thanks !
|
|
|
|
|
hi
in my app, i fill dataTable with some records include this columns :
DataColumn dcSpName = new DataColumn("SpName");
DataColumn dcParameterName = new DataColumn("ParameterName");
DataColumn dcSystemType = new DataColumn("SystemType");
DataColumn dcLength = new DataColumn("Length");
DataColumn dcIsOutputParameter = new DataColumn("IsOutputParameter");
as u can see, i want to load all stored procedures in my database with all parametersInfo, therefore, each new parameter for single sp cause new record insert into my dataTable object.
now, i want to remove duplicates rows from my dataTable objects to remain unique storedProcedures in my dataTable object, but how to remove them ?
thanks
|
|
|
|
|
You have this table just in memory ? Your easiest way is to not insert duplicates in the first place.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
no,
i want to get all information about stored procedures, then copy it to another dataTable abject and remove duplicates rows from it, but how to do ?
|
|
|
|
|
The info is coming from a stored proc ? Then your best bet by far is to ask the DB to remove doubles. If you're adding from more than one stored proc, I assume they are from different DBs for you not to use SQL, and again, your best bet is to check before you add.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
thanks Christian
my problem has been solved.
i was create new datatable named 'dtHelper' object and copy structure of my main datatable object, then add PrimaryKey to dtHelper and before add new row to it, check the current row with contains method.
thanks.
|
|
|
|
|
hello friends
I would like to know how to connect a C# application to a biometric device
Something like thumb impression device to C# application
Thank You
If You win You need not Explain............
But If You Loose You Should not be there to Explain......
|
|
|
|
|
Start by connecting the device to a computer, now where and how it is connect to the computer is relative information to how you are going to interface with it from your C# or whatever application.
Good luck
led mike
|
|
|
|
|
You're going to have to elaborate if you were hoping for any kind of useful answer.
Scott P
“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra
|
|
|
|
|
You are going to have to target the reader with an SDK from the manufacturer.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|
|
i am having a thumb impression reader ...
Which connects to my Pc ... to USB
Now in my software i need to show the info of a person whose thumb impression matches with the Stored impression of the biometric device
Got an idea using SDK ..
If anyone has used it before then please do reply
Thank You
If You win You need not Explain............
But If You Loose You Should not be there to Explain......
|
|
|
|
|
i'm working on a very simple time attendance web application
i'm saving the StartTime into SQL Server 05 Column.
what i need is to save the diffrence between the StartTime and the EndTime when the user is entering his leaving time.
my table is like that
Col1 :: col2 :: col3 :: col4
EmployeeID::StartTime::EndTime::TimeDiff
is there is any way i can do this
Ahmad AbuBakr
www.egyptvision.com
|
|
|
|
|
You can calculate different between DateTime instance from your application and store it in the database or you might make your TimeDiff column computed so that it stores difference between EndTime and StartTime (for example in seconds). You can use DATEDIFF[^] function for calculating difference between two dates in sql server.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|