I Define a user control that Inherits From Control Class
I want to show many instances of that class in a new class than inherits from Pannel Class
When I make instances and run this Code, there is no control in my Pannel:
Try using something like log4net or NLog both of which are free and easy to use, rather than rolling your own. I use log4net in a console application and it writes clear and concise log files with pipe-delimited fields; so easy to parse and view, if required. Very quikc and easy to set up and integrate into your code.
No real way to know what is wrong with your code if you don't provide samples/exceptions.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum
yup - while I have some issues with log4net (I use a custom startup so I can dynamically define where the log file goes based on where the app exe is located, rather than a fixed path/location for log files), I'd recommend it to anyone starting out using/needing logging
I have tried the Nlog tool. It worked well with one project, and when I tried to add it to another project, it was a complete mess. I was not able to add the config file specific to this second project.
I read that you need to install the tool, not having any pojects opened, just only the VS opened. I did that as well, but it was not straight forward.
Hello Everyone this is my first question I am posting!
I need help with a code
I need to count the same books I have added to a Binary File and show that number in the console but since I am new with these types of codes i am seeking for your help
This is the code i have Written to add the books to the file and I also have the code to read the files (if needed will post it) Now the problem is i don't know how to count the same book i have added multiple times and show it in Console. If anyone can help me i will appreciate it
If u need any explanation let me know and i will try to explain with my knowledge
Thanks in Advance
//method I am Using to Add Books to my Binary File
string addBook = "";
while (addBook != "No")
Console.WriteLine("Write the Books Identifiing number u want to add");
//book number i will need this to count the same books
int bookNumber = int.Parse(Console.ReadLine());
Console.WriteLine("Write Books Titttle");
string bookTittle = Console.ReadLine();
Console.WriteLine("Write th Authors Name");
string authorName = Console.ReadLine();
Console.WriteLine("Write the publishing company ");
string pubCompany = Console.ReadLine();
FileStream fsBooks = new FileStream("Books.bin", FileMode.Append, FileAccess.Write);
BinaryWriter bwBooks = new BinaryWriter(fsBooks);
Console.WriteLine("Do You Want to add another Book: 'Yes'/'No' ");
addBook = Console.ReadLine();
staticstring FillBlanks(string text, int size)
string blanks = "";
if (text.Length < size)
int difference = size - text.Length;
for (int i = 0; i < difference; i++)
blanks += " ";
elseif (text.Length > size)
text = text.Substring(0, size);
return text + blanks;
(btw, I think you should carefully consider if thats the most appropriate design for your file)
second, think about your problem like this... for every book read from your binary file, you want to store (possibly) the book title, and a count of how many times that title appears .. so, you could store the book title and a count in a dictionary or hashmap type object, eg
Dictionary <string, int> booktitle_counts;
So, every time you read a book, check if its already in the dictionay - if it is, increment the count for that book - else, insert the book and a count of '1'
At the end of reading your file back, you loop through the dictionary, writing the titles where count > 1.....
... and you have most of the code you need in ReadBooks
So, I would do a number of phases
1) copy all the code in ReadBooks() to a new method called (for example) ReadAllBooks
2) remove the input/check logic from ReadAllBooks so that it prints the entire file - make sure this works before proceeding !
3) Once (2) is working, add (for example)
Dictionary<String, Int> booktitle_counts = new Dictionary<String, Int>();
and the logic I outlined in my first reply for checking if a booktitle exists and adding it if it doesnt or incrementing the counter if it does already exist
4) Then you simply need to remove the book print code, and add some code to loop through the dictionary looking at the book title vs counts - big hint - look at the reference I gave you and see 'foreach'
Learn how to break your problems down into small chunks - then build up/extend code, making sure the basic parts work first, and each subsequent change works
Hello fellow coders, I was wondering if anyone ever experienced any latency in the button click when using the MVVM approach? I have 4 buttons and it seems when I click on either one initially there's a 3 second latency before the text changes and the other buttons become disabled. After that initial click it runs quicker. No matter which button it is on that first click it takes 3 seconds to respond then after that each button responds immediately. So here is what I'm doing.
1. I'm using the RelayCommand that was located in Josh Smith's article.
2. I have the following setup in my xaml behind my buttons. Each button has a different CommandParameter.
3. In the creation of my mobileViewModel I have the following code in the constructor. I assign the AddSaveUpdateContent property to update the text. Note, that this property has an OnPropertyChanged call inside.
_addSaveUpdateCmd = new RelayCommand(param => OnExecute(param), this.CanExecute);
AddSaveUpdateContent = "Add";
4. Inside the CanExecute is a case statement that gets the CommandParameter:
5. Inside the OnExecute is another case statement that gets the CommandParameter as well then calls another method:
6. Then in my PerformButtonTask method all I'm doing is is running through one more case statment to perform the appropriate task. The EnableFields and ClearFields are events that call a method in the code behind on the xaml page.
That's pretty much it. So, if anyone has any ideas please share. Thanks.
Update: Just to let you know. The problem is occurring in Visual Studio 2012 in debug mode; however, when I create my executable the response is immediately as expected. So, is because of the development environment?