|
Thanks for the explanation
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi I am new to c# coding and I am having problems with some basic things I keep getting error codes CS1519,CS1031,CS8124
Console.writeline("Hello and welcome to the number guessing game!");
|
|
|
|
|
C# is a case sensitive language: which means that Console is not the same thing as console - and that applies to everything. UPPERCASE and lowercase characters are considered to be very different. If you create a variable called MyString then you can't use it by typing mystring , myString , Mystring , or any other variation.
In this case, your code is trying to call a method called WriteLine and the case sensitivity is catching you:
Console.WriteLine("Hello and welcome to the number guessing game!"); Should get rid of those errors.
But the error numbers you are getting implies there are a lot of other errors there, which we can't see - remember that we can't see your screen, access your HDD, or read your mind; we only get exactly what you type to work with - which are "forcing" error to come up on that line.
Chances are you need to look closely at the first line that an error is being reported on and see what the error message says as it may be causing other problems.
A valid C# file should look something like this:
using System;
using ... other namespaces being used ...
namespace MyNamespaceName
{
static class MyProgramName
{
static void Main()
{
...
}
}
} So if yours doesn't that may be a problem.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hello, I'm pretty new to C#, it is one of my subjects of my studies this semester, so thanks for beeing patient
I was trying to make the card game Black Jack for one of my assignments, but I have reached a problem which i don't know how to fix without getting a horribly long code.
I have put in a couple of picture boxes for the card pictures to load into, and when I Click the "Hit" button, I want the card that is choosen at random to be loaded into picbox1, next time i press it i want it to load to picbox2 and so on...
But I have no idea how to code the method to know which picbox to load into
here's a picture of my layout:
<"https://imgur.com/a/zbucNcB">
Sorry if I made any mistakes explaining, It's my first time posting here.
many thanks in advance for any help!
modified 4-Oct-18 17:11pm.
|
|
|
|
|
I would have collection of containers (pictureboxes) when you hit create a new container, add the card image and add the container to the collection.
Your UI should be able to display the collection of containers (listbox etc) rather than a limited number of containers.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thank you for your reply!! It's late here right now, but I'll read up on it tomorrow after lectures to see how it works!
|
|
|
|
|
1. keep a list of PictureBoxes.
2. use an integer counter variable as an index to the next PictureBox to be used.
3. reset the index when needed.
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
|
|
|
|
|
in Common.c
typedef unsigned char UN_Char;
typedef enum { Valid = 0, Invalid = 1, Unknown = -999 } AppResponseCode;
Method in SomeApi.C , need to Call from C#
static AppResponseCode SomeFunction(UN_Char ** vUC1PtrPtr,size_t * vSize1Ptr, UN_Char * vUC2Ptr,size_t vSize2, FILE * inputFile, char * vcharPtr)
I tried to add reference of provided C application DLL but Error appear
A Reference to '.....\SomeApi.DLL' could not be added. Please make sure that the file is accessible, and that it is valid assembly or COM Component
So the other option I have is to use DLLImport
[DllImport("SomeAPI.dll", CharSet = CharSet.Unicode)]
public static extern AppResponseCode SomeFunction( ????? );
But I don't know what parameter types I had to pass for Return and Calling parameters to Call and obtain value from SomeFunction()
PS: Though I have source code for Complete C application but I can't re-compile it or modify it, I am only allowed to work with available Exe/DLL
|
|
|
|
|
Hi,
you will need P/Invoke stuff, DLLImport is part of that.
I once wrote an introductory article on it, see Article: P/Invoke, part 1[^].
You will have to figure out whether your C code is built for 32-bit or 64-bit, and make sure your C# app is built for the same width.
Pointers become IntPtr , which will take 32 or 64 bits depending on your app build settings, and both parties must agree!
I am worried about your FILE* , as FILE really isn't a managed beast. At best, you only have to pass it (as a pointer to whatever, say an int) from one C function to the next. I would never consider sharing file metadata between managed and unmanaged code; if needed I would pass a path to the unmanaged world and have it open, process and close the file all by itself.
For the return value (an enum ), you could simply cheat a little and declare it as an int .
Good luck!
modified 4-Oct-18 23:03pm.
|
|
|
|
|
|
Hi,
We have a search form in asp.net and based on the selected fields/ Options we are forming a dynamic query. I want to cache this query so that if any other user is trying to search the same thing I can just return the cached output instead of re-executing the query. Our environment is C# asp.net with DB2 as the backend. We are using plane ado.net not MVC.
Can anyone please let me know or guide me what to implement.
Thanks
|
|
|
|
|
What have you tried?
Where are you stuck?
What help do you need?
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
What help do you need?
I need help in implementing caching the query at the application level.
|
|
|
|
|
It's going to be one of those ...
What help do you need?
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with. No context, no idea what you have actually tried or what happened when you did, nothing.
Help us to help you ...
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I have a form where we can search the information using "User Name", "email" and "zipcode" from the USERS table which has 900,000 records.
For Example User1: searches the information using "test@gmail.com" email address and User2 is also doing the same search after 5 min then I do not want to re-execute the query instead I want to display the results from Cache. My back end is DB2.
I am using OdbcCommand.
USER table has UserID, UserName, Email, Address1, Address 2, Zipcode, State
|
|
|
|
|
It's simple. All you have to do is Google for "mvc cache database results". Start reading and find something that's appropriate for your situation.
Remember though. Server's don't have infinite memory! Be careful what you cache.
|
|
|
|
|
We are not using MVC. We are using ado.net only
|
|
|
|
|
You just compared apples and oranges.
MVC is an ASP.NET web application framework.
ADO.NET is a database querying framework.
In any case, the advice is still the same. Caching is handled at the application level, so if you're using ASP.NET, just change the application type in the Google search.
|
|
|
|
|
1.) What makes you think there's a problem? (Your "example" looks like it will retrieve only one record from a "trivial" database of 900K records). All queries have a "first time" cost due to server data paging that is reduced for subsequent queries hitting the same pages.
2.) What are the the odds that 2 people are running the exact same query at the same time?
3.) How do you insure you are not caching and then returning "stale data"?
(Think hard about the consequences of #3)
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
1) What makes you think there's a problem? -- I agree with and my users are ok with this
2)What are the odds that 2 people are running the exact same query at the same time? -- Different users will be using the same query for at least 7- 8 times in a day
3) How do you ensure you are not caching and then returning -- Right now I am using HttpContext.Current.Cache.Get and comparing the parameter value which is not great. It will only work if the same user. But I want to implement at the application level.
Thanks
|
|
|
|
|
#3. No, you missed the point.
When you cache the data from a search query, then the database is updated with new data, how are you going to detect this and invalidate the cached copy of the data so a new search of the same query terms results in an updated dataset?
THIS is what you have to watch out for.
|
|
|
|
|
When you cache the data from a search query, then the database is updated with new data, how are you going to detect this and invalidate the cached copy of the data so a new search of the same query terms results in an updated dataset? God question this is not transactional data and we update data once in a day so i will just cache the query for the half day or 4 hours only.
|
|
|
|
|
Yeah, that's not going to work. Putting an arbitrary value on an items "time to live" will just result in search queries that could be out of date for a smaller period of time.
The code that updates the database has to be able to invalidate cached data. But you have a problem. How is your code going to know which cached queries are affected by a single update to the database?
Caching search queries is a bad idea.
|
|
|
|
|
Dave is absolutely right - by trying to cache data outside of the DB that you are sourcing from, you need to catch everything that happens to your DB and invalid specific portions of your cache if the change might have affected the results of a query. Otherwise, your cached data becomes increasingly out of date and useless.
For example, I issue a stock level request for Product A, and you return "2".
Next time I ask, it's in your cache, so you return "2" without going to the DB.
Then Joe over there sells one, and the DB gets updated to "1"
I ask again, it's in your cache, so you return "2" without going to the DB.
Joe sells anoth, and the DB gets updated to "0"
I ask again, it's in your cache, so you return "2" without going to the DB.
So the customer I'm talking to "knows" there are 2 in stock - and buys one. What happens now?
Unless you "stand in the middle" and pass each query through or serve them from your cache while intelligently invalidating the caches as appropriate, your data gets more and more irrelevant.
And that is going to slow down the whole process as well, because now you have effectively two sources of data processing every single command!
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I'm curious - your answer to 1 seems to imply that you and your users don't perceive a problem!
What is the latency on your results return, it seems to me that a query on a 900k should be trivial from a database POV. If it IS the database then look at indexing the user table, if the latency is the network then you have a different problem which should be resolved by your network people not by caching search results.
Never underestimate the power of human stupidity
RAH
|
|
|
|