My question is about how to get a stack out of a queue. The program should work by generating stacks (shown below), having those stacks stuffed with data (also shown below), then unloading and displaying the data in them. Right now it just throws a CS1061 exception at me. The 5 is there for example, the actual code is picking a random string from an array.
public void newCustomers()
{
var customer = new Stack();
store.Enqueue(customer);
}
public void Shop()
{
var customer = store.Dequeue();
customer.Push(5);
//^currently this doesn't work. I'm assuming the typing for customer is wrong.
store.Enqueue(customer);
}
CS1061
Severity Code Description Project File Line Suppression State
Error CS1061 'object' does not contain a definition for 'Push' and no accessible extension method 'Push' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
You're using the non-generic Queue class. The Dequeue() method returns an object that you would have to cast to Stack:
var customer = (Stack)store.Dequeue();
customer.Push(5);
I would suggest using the generic queue class Queue<T> instead.
Related
I'm currently trying out the code for "Create a Customer Payment Instrument" by using their sample code and I am getting an error on this line.
var configDictionary = new Configuration().GetConfiguration(); error is "The type or namespace 'Configuration' could not be found".
Quick fix shows me to add one of these two Using statements: using CyberSource.Client; or using CyberSource.Clients;.
But this gives me another error - 'Configuration' does not contain a definition for 'GetConfiguration' and no accessible extension method 'GetConfiguration' accepting a first argument of type 'Configuration' could not be found."
There isn't much documentation so I am unsure how to fix.
I am trying to get a variable "isOffRoad" from script "WheelHandler" in the object "Wheel1".
I am getting the error:
Assets\Scripts\CarControler.cs(53,13): error CS1061: 'GameObject' does not contain a definition for 'WheelHandler' and no accessible extension method 'WheelHandler' accepting a first argument of type 'GameObject' could be found (are you missing a using directive or an assembly reference?)
Thanks in advance.
Edit: isOffRoad is public.
public GameObject Wheel1;
void Update()
{
if(Wheel1.WheelHandler.isOffRoad == true)
{
Debug.Log("offroad");
}
}
You need to access your component with GetComponent<>() method.
In your case that would be Wheel1.GetComponent<WheelHandler>().isOffRoad
Also It is not recommended to access component in Update loop. It would be better to cache it in a field.
Try this one:
if (Wheel1.GetComponent<WheelHandler>().isOffRoad))
{
// do something..
}
I want to search all the telegram channels available with this :
var clientApi = await ClientFactory.BuildClientAsync(settings).ConfigureAwait(true);
IDialogs userDialogs = await clientApi.MessagesService.GetUserDialogsAsync(100).ConfigureAwait(true);
and then get the chats, so channels like this :
var s = userDialogs.Chats.AsEnumerable; //.Chats.asEnumerable();
but I can't compile it because it's throwing this error :
Error CS1061 'IDialogs' does not contain a definition for 'Chats' and no accessible extension method 'Chats' accepting a first argument of type 'IDialogs' was found (is a using directive or assembly reference missing?).
I'm using OpenTl and when I try to debug it, the userDialogs as an attribute Chats, as well as some others.
OpenTL library
I'm a beginner at writing and understanding C#. I would like to know how to reuse some code I have that updates a WebService username and password credentials.
Here is code in 1st cs File:
...
public class AuthenticateLogin
{
public static object PassCredentials()
{
ServiceName.UsersClient clientauthentication = new ServiceName.UsersClient();
clientauthentication.ClientCredentials.UserName.UserName = "user";
clientauthentication.ClientCredentials.UserName.Password = "pwd";
}
}
...
Here is code in 2nd cs File:
var test = AuthenticateLogin.PassCredentials();
Console.WriteLine(test.EchoAuthenticated("Successful Login"));
Error Received:
Error CS1061 'AuthenticateLogin' does not contain a definition for 'EchoAuthenticated' and no accessible extension method 'EchoAuthenticated' accepting a first argument of type 'AuthenticateLogin' could be found (are you missing a using directive or an assembly reference?)
Solution desired:
In the second file, I want to be able to use the methods in the 'clientauthentication' of the first file. I need to be able to use the 'clientauthentication' like a common object in multiple other cs files. FYI: I can use the 'clientauthentication' methods fine in the 1st file and it works okay.
Has anyone ran into problem where you just can't use the PageOrientation property in your C# WPF project? I have tried everything, put it still says:
"The name 'PageOrientation' does not exist in the current context".
I have all usings included, just can't figure it out.
Here's my printing method:
private void btnPrindi_Click(object sender, RoutedEventArgs e)
{
PrintDialog prtDlg = new PrintDialog();
if (prtDlg.ShowDialog() == true)
{
**prtDlg.PrintTicket.PageOrientation = PageOrientation.Landscape;**
Size pageSize = new Size(prtDlg.PrintableAreaWidth - 30, prtDlg.PrintableAreaHeight - 30);
gridKaart.Measure(pageSize);
gridKaart.Arrange(new Rect(15,15,pageSize.Width,pageSize.Height));
prtDlg.PrintVisual(gridKaart,"Patsiendikaart");
}
}
The error actually refers to the enumeration (PageOrientation.Landscape) on the right hand side of your assignment.
If the property did not exist you would receive (try compiling "".Y and you'll see what I mean):
'string' does not contain a definition for 'Y' and no extension method 'Y' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)
Compare this to Aoeui.Dhtns:
The name 'Aoeui' does not exist in the current context
You are likely missing a namespace reference required, like System.Printing:
// ...
using System.Printing;
// ...
The other possibility is you have not referenced ReachFramework.
If you have, your code compiles as-is: