C#

94K

Solutions

25K

Contributors

C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).

Share tech news, updates, or what's on your mind.

Sign up to Post

Hi Team,

Have been using C#, Visual Studio 2015, POM architecture. Problem is: sometimes tests passes and sometimes tests gets failed. So far what I tried is increased the explicit time but efforts so far in vain.

Also searched over the net and found that need to use webdriverwait which looks is missing as I am unable to use that. as the message says 'OpenQA.Selenium.Support.UI Namespace does not contain WebDriverWait class'.

Please help.
0
Hi All,


I want to develop a application for starting and stopping VMs , it will utilise Azure powershell . should I use powershell and wpf or c# and wpf, if I develop in c# the guide interface, can I call powershell commandlets? is c# more flexible for developing wpf guis than powershell?

thank you in advance,
kelly
0
Practicing some sample Numerical Reasoning questions on TestDome

How do I go about this?
X is total number of shares
X/2 because brother and sister each own half
(X/2) - 12000? (I don't think so)

There's a hint but nothing jumps out with that hint.

t1.png
EDIT I googled and the answer is this but how to get to it?

t2.png
0
Practicing TestDome's sample test. Why is the answer below is correct? If I add Glacier's row and divide by 3, I get 7.6 and if I add Rainforest and divide by 3, I get 7.3

Shouldn't Rainforest be correct?

t2.png
0
I'm practicing TestDome sample free questions. What's the answer to this question?

For example, I'm looking at "John".. . did he sell 4 or 10? so... do I need to add 0+1+2+3+4 or does it mean John sold 4?

I came up with 18 which is not correct

t1.png
0
I'm practicing the free test https://www.practiceaptitudetests.com/numerical-reasoning-tests/

Question #2's solution... where is 1.26 coming from?

t1.png
0
Experts,
 I have sharepoint 2013 environment and i was working on to find current user belongs to AD group or not by java script. We have web services created to check current user  part of AD or not by passing Groupname ,  Domain and username.  For some reason i am not getting username if user does not have access. But I am getting userid from _spcontext.

I have a rest api to get the username from userid. It's not getting 401 error who does not have access to that site so i am planning to use server side code with Runwithelevated access.

Can you please help me to write code so i can just pass userid and it's retrieve username and domain form user profile?

var userid= _spPageContextInfo.userId;
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + userid + ")";
var requestHeaders = { "accept" : "application/json;odata=verbose" };
$.ajax({
    url : requestUri,
    contentType : "application/json;odata=verbose",
    headers : requestHeaders,
    success : onSuccess,
    error : onError
});

Open in new window



Over all Code

Open in new window

0
The SnowStorm and RainStorm classes inherit from the Storm class.  How do I amend the constructors and the IsInEyeOfTheStorm method to use inheritance properly?
This is not a homework question for an assignment.


  public class RainStorm : Storm
    {

        public RainStorm(double eyeRadius, Tuple<double, double> eyePosition)
        {
            this.EyeRadius = eyeRadius;
            this.EyePosition = eyePosition;
        }

        public bool IsInEyeOfTheStorm(Tuple<double, double> position)
        {
            double distance = Math.Sqrt(Math.Pow(position.Item1 - EyePosition.Item1, 2) +
                                        Math.Pow(position.Item2 - EyePosition.Item2, 2));
            return distance < EyeRadius;
        }

        public double AmountOfRain()
        {
            return EyeRadius * 20;
        }
    }

    public class SnowStorm : Storm
    {


        public double AmountOfSnow { get; private set; }

        public SnowStorm(double eyeRadius, Tuple<double, double> eyePosition, double amountOfSnow)
        {
            this.EyeRadius = eyeRadius;
            this.EyePosition = eyePosition;
            this.AmountOfSnow = amountOfSnow;
        }

        public bool IsInEyeOfTheStorm(Tuple<double, double> position)
        {
            double distance = Math.Sqrt(Math.Pow(position.Item1 - EyePosition.Item1, 2) +
                                        Math.Pow(position.Item2 - EyePosition.Item2, 2));
            return distance < 

Open in new window

0
I want to create an internal webpage on my current IIS Windows 2016 server that displays "ALL Active Directory Users"
  ** including their Active Directory photo that already displays via my onPremise Exchange server

What do you recommend ?

Below are a few ideas I found, but would also like input from others
============================================================
http://demo.ithicos.com/directorysearch
  ** $249 onetime cost

https://community.spiceworks.com/scripts/show/1002-employee-directory-with-photo-s

https://gist.github.com/cainejunkazama/6178122

https://dovestones.com/active-directory-phone-book/

https://4sysops.com/archives/creating-a-company-directory-web-page-generated-from-active-directory/
0
Tips to mastering Sitecore

I have a rare opportunity to invest lots of time into learning Sitecore, in preparation for a job integrating Sitecore with a .NET MVC application. So, the more I learn now, the further I can go in implementing Sitecore.

What videos and topics can you suggest I did into to make the most out of this one month deep dive into Sitecore.

And what related technologies might I also consider?

Thanks
0
I have the following
 

List<SearchSubscribers> sbsc  = new DbList().SearchMembers(SubscriberId.Text);

Open in new window


sbsc.SubscriberType has many different types.  Is there any way with a single lambda expression that I can remove all but a certain type?

something like this
 sbsc.RemoveAll(sbsc=> sbsc.SubscriberType  == "Paid");

I am sure I can do this with two objects and a foreach(){} loop, but would like to see if I can do it neat in a single expression if possible
0
I'm using a third party to create pdfs. I build the template on their site. I do a GET with my data and poof, a nice pdf. In PostMan this works great, the message I get in Post man is: This response could not be previewed. Download the response to open it with an appropriate application. When I click "Download" a file save dialog opens and it's already got the file name populated as xxxxx.pdf. Save the file and open it. It works great.

Now I'm trying to do the same from a WPF C# app. I'm using the RESTSharp library to make the call. My latest attempt, after setting the headers and params just like Postman, is:
client.DownloadData(request).SaveAs("c:\\ajson\\some.pdf");

Open in new window


I get a blank pdf.

I've also tried

 await Task.Run(() => ReceiveMyString(this));

Open in new window


and parsing the response in the ReceiveMyString method. I'm getting the data but I just can't figure out how to save it as a pdf. All attempts end with a corrupt pdf. Here's one example:
 byte[] buffer = Encoding.ASCII.GetBytes(response.Content);
            MemoryStream ms = new MemoryStream(buffer);
            FileStream file = new FileStream("C:\\ajson\\myPDF.pdf", FileMode.Create, FileAccess.Write);
            ms.WriteTo(file);
            file.Close();
            ms.Close();

Open in new window


Thank you!
0
Hello EE,

Im trying to do this linq query :


            Dim qx = (From m In MyItems
                         Where arrString.All(Function(v) m.Value.Contains(v))
                         Let row = rowID
                         Let myKey = m.Key
                         Let myValue = m.Value
                     ).OrderBy(Function(n) n.myKey) _
                      .Select(Function(t) New With {t.row, t.myKey, t.myValue})

Open in new window



it does not stops while running my software, but if I place a breakpoint, and I try to see whats inside "qx", it says : Error Type expected"

the goal is to return 3 variables, (Row, myKey, myValue),  thats why I cannot do  .ToDictionnary() or .ToList()  I thought I needed to do Select New With since I have more than 2 varaibles

also I wanted to OrderBy in my LINQ
do you see any problem looking at it ?
0
I am getting the error :
System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near 'up'.
Incorrect syntax near the keyword 'OR'.
Incorrect syntax near ')'.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)


Below is my query , can anyone please help.

commLite.Parameters.Clear();
                    commLite.CommandText = "INSERT INTO UserProfile (UserProfileID,Name,Password,AuditTypeID,ContactID,UserType,UserEmail) " +
                        "VALUES (@UserProfileID,@Name,@Password,@AuditTypeID,0,@UserType,@UserEmail)";
                    commLite.Parameters.Add(new SQLiteParameter("@UserProfileID"));
                    commLite.Parameters.Add(new SQLiteParameter("@Name"));
                    commLite.Parameters.Add(new SQLiteParameter("@Password"));
                    commLite.Parameters.Add(new SQLiteParameter("@AuditTypeID"));
                    commLite.Parameters.Add(new SQLiteParameter("@UserType"));
                    commLite.Parameters.Add(new SQLiteParameter("@UserEmail"));

                    comm.CommandText = "SELECT up.UserProfileID,up.Name,up.Password,up.AuditTypeID,up.ContactID,up.UserType,up.UserEmail" +
                        "FROM UserProfile up " +
                        "WHERE up.Active=1 AND up.InUse=1" +
                        (whereUserProfileIds == string.Empty ? string.Empty : " AND up.UserProfileID IN (" + …
0
Hi,

Let’s say I have a statement like

[code]int t = await Task.Run(() => Allocate());

And Allocate looks like the following:

Allocate()
{
    Int I;
}[/code]

If multiple tasks then say call allocate (sorry my example needs to be a bit better)

Does each one create its own instance of Allocate() so if say the are 5 running tasks the will be 5 copies of I.

Or is there only one instance so if I change i’s value to 10 then it will be 10 every where.

Sorry don’t know how to frame the question better.

Thanks
Ward
0
I had an interview a couple of weeks ago and the guy asked me why APIs are called Restful. I said because they're stateless. I said with Web APIs, data is transferred via HTML and it can be XML , JSON, but Web Services can only be XML. (Something like that... of course I was nervous)

I didn't answer his question. I've been googling and reading about APIs for another interview I have today. What's the answer to that question?
0
I am trying to get website visitor geo location. And my research has the following.

1. using html5 geo Javascript but the down side is to request permission (Yes/No) from the website visitor.
2. make a text box and allow the website visitor to enter his/her own address or zip and convert to lat and lng.
3. using IP address and try to convert into lat and lng. but it has issues on the proxy sometime, and using those IP address provider will only return server IP since the codes is resided in the server.

my question is:
1. Do you know any softare vendor that I can pay for subscription fee to get the visitor's geo location? I see some website they can get very accurate information.
2. Or do you know any ways to write code in c#/mvc/javascript to make it working?
0
I have c# aspx.net with ms SQL server and have one question about SQL

assume I have a web form and come with start date and end date. the format is 20181201 and 20181231 and they are an integer.
and I have to run a SQL statement like below.

select top 1 * from transacation_history where deposit_date >= 20181201 and deposit <= 20181231
Or
I should use between statement? but I do not know how to do that.
1. Which one run faster?
2. I will convert it into stored procedure. In this logic, is it best practice in ms sql?

Thanks.
0
What is the difference between a class, struct, and static class?

How would you decide to use a interface?
0
I have a web server in an AWS VPC.  
Only about 50 IP Addresses are open to see the page on this server.  I filter the IP addresses through Security Group, so if someone is not authorized, they cannot touch the machine at all..
 The issue I am running into is that all of the folks that cannot get in simply spin and timeout.  I would like them to get a message "You are not authorized to view this site".  How can I do that before I hit the page?
 I need to be able to check with the users IP address.

Thank you ion advance,
0
Pros and more Cons of using SASS on a new MVC website?

I have not used SASS but hear it produces perfect CSS files. One downside is that everyone who needs to create classes must learn the SASS scripting language. Another may be that debugging time is much higher.

Are there, instead, good coding practices that all developers can follow, so they can avoid the negatives of using SASS and get some of the benefits of using standardized CSS?

(I am not sure if the MVC site will use the Razor View Engine, but does this change your opinion of using SASS?)

Thanks
0
What .NET Technologies in a New MVC Application?

If you needed to architect a new  .NET MVC Application today, what would it consist of?

What version of .NET, MVC, might it be?
And what about Dependency Inversion?
What about Unit Testing?
What is your preferred Unit Test Framework?
What about AutoMapper?
How about a MOQ tool?

And what else am I forgetting to mention?

Thanks
0
Please explain .NET Standard 2.0 and open source.

and how code reuse is enhanced by giving me an example or two of how this is a benefit. For example, a library that can be re-used between various platforms.

And is .NET Standard 2.0 a part of the open sourcing of the .NET Framework? Or is it MVC that is open sourced?
Thanks
0
Difference between URL forwarding and re-routing?

I am curious what the difference is from an MVC .NET Framework perspective, if that makes any difference...

Thanks
0
I'm using Visual Studio 2017 with C#.
I have a method like this.  It's supposed to convert a string to an integer.  If the string does not meet certain conditions there is an exception.
What's the best way to let whatever called this method know the details of the exception?

        public int GetScore(string s)
        {
            try
            {
                int score = 0;
                int totalScore = 0;
                string individualCard = "";
                bool oneJokerFound = false;
                bool twoJokersFound = false;
                int number;
                if (s == null)
                {
                    return 0;
                }
                else if (s == "")
                {
                    return 0;
                }
                for (int i = 2; i < s.Length; i += 3)
                {
                    if (s.Substring(i, 1) != ",")
                    {
                        throw new Exception("Incorrectly formatted string");
                    }
                }
                s = s.Replace(",", "");
                do
                {

}

Open in new window

0

C#

94K

Solutions

25K

Contributors

C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).