Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the differences between C # and Lua language learning

2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "what are the differences between C# and Lua language learning". In daily operation, I believe many people have doubts about the differences between C# and Lua language learning. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "what are the differences between C# and Lua language learning"! Next, please follow the editor to study!

The grammatical basis of Lua

As a programming language, Lua is very different from C #. So before using it, we should first make clear what are the characteristics of Lua language by comparison.

Language characteristics

First of all, there are obvious differences between Lua and C # in terms of language features:

Language type: Lua is a parsed language, and this code is executed in the order from top to bottom. While C # is a compiled language, after writing, it will generate a special file, and then call the function according to the calling relationship.

Data types: Lua is a weakly typed language, so you don't need to specify a data type when a variable is declared. C # is a strongly typed language. Data types must be specified for defining data.

Writing format

Functional relationship: functions in Lua do not have a clear attribution class and exist independently. The functions in C # belong to the class.

The ending is different: each line of C # code must end with;, and the Lua code can end with;, or there can be no punctuation at the end.

Variable writing format: C # declares variables in the format of data type identifier = value; the Lua language does not specify data types.

Basic data types of Lua

Numeric type: the numerical type of Lua. Only number,C# has int,float,double.

Boolean type: C # is bool and Lua is boolean

String type: both the string type of Lua and the string type of C # are string, and the escape characters are basically the same. However, the string of Lua can be wrapped by "" or''or [[]],''and "" contain basically the same string (because the content is also a string, so Lua has no char type), and the string wrapped by [[]] is equivalent to adding @ to the string of C#, thus output in the original format.

Operator of Lua

Addition: the plus sign in C # indicates the addition of 2 numbers or 2 strings, but in Lua it uses "…" (2 points).

Composite operators: composite operators and + +,-- two special operators are not supported in Lua.

Operators of different forms: Lua is not equal to ~ =, C # is! =. The logical operator and,or,not,C# in Lua is & &, | |,!.

The branch structure in Lua Zhengzhou birthmark removes which good http://m.zykdbh.com/

There is no {} in the branch structure in Lua, using then... End... Instead. An if (a Boolean expression) is followed by a then, followed by a new line followed by an end after the block of code is written. Also, there is no switch in Lua. Case... Statement.

Loop structure in Lua

The loop structure in Lua also does not have {}, using do... End... Instead.

The for loop of Lua is written in the form of for initial value expression, final value expression (including equals), and iteration represents the expression.

There is no do in Lua... While ()... Loop statement, but has a similar loop statement, which is repeat. Until ()... Statement, and do... While ()... Unlike, when the conditional expression is true, it ends the loop, otherwise it always loops. The out-of-loop keyword in Lua has no continue, only break.

The function structure of Lua

The return value of the function in C # is replaced by function, and it still ends with end. Again, there is no {} in the function structure of Lua.

Because Lua is an analytic language, the order of execution is from top to bottom. So the function call in Lua must be written after the function declaration. And whether the function has a return value depends on whether it contains return.

There is no concept of delegation in Lua, and functions can be passed directly as parameters.

At this point, the study of "what is the difference between C# and Lua language learning" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report