C#help - 我也没有在visual studio中使用任何库来编写这些函数的代码。我也只允许使用数组。 [英] C# help - I have too write the code for these functions without using any libraries in visual studio. I am also only allowed to use an array.

查看:51
本文介绍了C#help - 我也没有在visual studio中使用任何库来编写这些函数的代码。我也只允许使用数组。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我声明的数组是:

int [] set = new int [] {1,2,3,4,5};



我必须为以下两个函数编写代码而不使用任何库而不使用LINQ。

我很挣扎,不知道从哪里开始。



clear_set:删除集合中的所有元素;什么都不返回。



is_empty:检查集合是否为空并相应地返回布尔值true或false。



希望有人可以提供帮助。



谢谢。



我尝试了什么:



我还没有尝试过任何东西。我坐着盯着视觉工作室徘徊我将如何接近这个。

The array i have declared is:
int[] set = new int[] { 1, 2, 3, 4, 5 };

I have to write code for the two functions below without using any libraries and no LINQ.
I am struggling and have no idea where to start.

clear_set : removes all elements from the set; returns nothing.

is_empty : checks whether the set is empty and returns the Boolean value true or false, accordingly.

Hopefully someone can help.

Thanks.

What I have tried:

I have not tried anything yet. I'm sat staring at visual studio wandering how I am going to approach this.

推荐答案

我们不提供免费服务与家庭作业,你必须自己做。但是,这些是基本数组,删除元素意味着将它们设置为null - 但如何在C#中将值类型设置为null?这个问题是第一个答案。



此外,如果数组为空,则表示其中没有元素。您可以使用一个属性 Length ,然后返回一个值,指示数组是否为空。这是你的第二个问题的答案。编码出来。



每当您发现自己遇到与C#编程相关的问题时,请参阅本文档教程并阅读其中的部分内容。 C#编程指南 [ ^ ]。我建议任何开始学习C#的人。
We do not provide free services with homeworks, you have to do it yourself. However, these are basic arrays and to remove the elements means to set them to null — but how can you set a value type to null in C#? That question is the first answer.

Also, if an array is empty, it means it has no elements in it. There is a property, Length, that you can use and then return a value indicating whether the array is empty or not. This is the answer to your second question. Code them out.

Whenever, you find yourself in a trouble related to C# programming, go to this documentation tutorial and read the sections of it. C# Programming Guide[^]. It is my recommendation to anyone starting to learn C#.


对于谷歌这样的短语,如C#clear array和C#check array is filled这样的短语比输入了问题。



具有讽刺意味的是,编写代码的时间比写这个答案要少,但是我不打算为你做功课。 />


懒惰的事情是,当你花更多的时间来避免工作而不是做这件事时,它会适得其反。如果你不擅长懒惰,学习编码可能是一个很好的备份计划。
It would have taken less time to Google such phrases as "C# clear array" and "C# check array is populated" than it would to have typed out the question.

Ironically, it would also take less time for me to write the code than to write this answer but I'm not going to do your homework for you.

The thing with laziness is that it becomes counterproductive when you spend more time avoiding work than doing it. If you're no good at being lazy, learning to code might be a good back-up plan.


我们不做你的HomeWork。

HomeWork是不会在乞求其他人做你的工作时测试你的技能,它会让你思考并帮助你的老师检查你对所学课程的理解以及你应用它们时遇到的问题。

你的任何失败都会帮助你的老师发现你的弱点并设定补救措施。

所以,试一试,重读你的课程并开始工作。如果您遇到特定问题,请显示您的代码并解释这个问题,我们可能会提供帮助。



作为程序员,您的工作是创建算法解决特定问题,你不能依赖别人永远为你做,所以有一段时间你必须学会​​如何。而且越快越好。

当你要求解决方案时,就像试图通过培训其他人来学习开车一样。

创建算法基本上是找到数学并做出必要的调整以适应你的实际问题。



发展的概念就像这个词所暗示的那样:系统地使用科学和满足特定目标或要求的技术知识。 BusinessDictionary.com [ ^ ]

这与有一个不一样快速谷歌并放弃,如果我找不到正确的代码。
We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.

As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.

The idea of "development" is as the word suggests: "The systematic use of scientific and technical knowledge to meet specific objectives or requirements." BusinessDictionary.com[^]
That's not the same thing as "have a quick google and give up if I can't find exactly the right code".


这篇关于C#help - 我也没有在visual studio中使用任何库来编写这些函数的代码。我也只允许使用数组。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆